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

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

Instance Method Summary collapse

Instance Method Details

#before_destroyObject

Raises:



49
50
51
52
# File 'lib/model/super_record/protection.rb', line 49

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

#record_protected?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/model/super_record/protection.rb', line 34

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

#set_record_protectedObject



38
39
40
# File 'lib/model/super_record/protection.rb', line 38

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

#set_record_protected!Object



42
43
44
45
46
47
# File 'lib/model/super_record/protection.rb', line 42

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