Module: Abbish::Sequel::Plugins::Model::RecordProtection::InstanceMethods

Defined in:
lib/model/record_protection.rb

Instance Method Summary collapse

Instance Method Details

#before_destroyObject



48
49
50
51
# File 'lib/model/record_protection.rb', line 48

def before_destroy
  super
  raise RecordProtectedError, self.class.record_protection_options[:raise_protected_message] if record_protected?
end

#record_protected?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/model/record_protection.rb', line 33

def record_protected?
  self.class.record_protection_options[:enabled] ? send("#{self.class.record_protection_options[:column_protected]}") == 1 : false
end

#set_record_protectedObject



37
38
39
# File 'lib/model/record_protection.rb', line 37

def set_record_protected
  send("#{self.class.record_protection_options[:column_protected]}=", 1) if self.class.record_protection_options[:enabled]
end

#set_record_protected!Object



41
42
43
44
45
46
# File 'lib/model/record_protection.rb', line 41

def set_record_protected!
  if self.class.record_protection_options[:enabled]
    set_record_protected
    self.save
  end
end