Skip to content

Instantly share code, notes, and snippets.

@aktowns
Last active December 11, 2015 08:08
Show Gist options
  • Save aktowns/4570583 to your computer and use it in GitHub Desktop.
Save aktowns/4570583 to your computer and use it in GitHub Desktop.
#config/initializers/datamapper_readonly.rb
module DataMapperReadOnly
def read_only!
[:valid?, :create, :update, :save, :destroy].each do |t|
before t do
raise Exception.new "read-only class attempted write"
end
end
end
end
DataMapper::Model.append_extensions DataMapperReadOnly
#app/models/Release.rb
class Release
include DataMapper::Resource
storage_names[:default] = 'releases'
read_only!
#..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment