module BeReadonly::Model::ClassMethods

Public Instance Methods

be_readonly() click to toggle source
# 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