Module: Abbish::Sequel::Plugins::Model::SuperRecord::Protection

Defined in:
lib/model/super_record/protection.rb

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Constant Summary collapse

ProtectedError =
Class.new(::StandardError)

Class Method Summary collapse

Class Method Details

.configure(model, options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/model/super_record/protection.rb', line 8

def self.configure(model, options = {})
  options = {
      :enabled => true,
      :feature_column_protected => :record_protected,
      :raise_protected_message => 'Cannot destroy protected record',
  }.merge(options)

  Abbish::Sequel::Plugins::Model::SuperRecord.check_feature_column model, options[:feature_column_protected]

  model.instance_eval do
    self.record_protection_options = options
  end
end