Module: BeReadonly::Model::ClassMethods

Defined in:
lib/activerecord-be_readonly/model.rb

Instance Method Summary collapse

Instance Method Details

#be_readonlyObject



6
7
8
9
10
11
12
13
# File 'lib/activerecord-be_readonly/model.rb', line 6

def be_readonly
  extend BeReadonlyClassMethods # intentionally not in ClassMethods which is automatically extended via ActiveSupport::Concern
  include BeReadonlyInstanceMethods # intentionally not just InstanceMethods as those would be automatically included via ActiveSupport::Concern

  before_destroy do
    raise ActiveRecord::ReadOnlyRecord if BeReadonly.enabled
  end
end