Module: Abbish::Sequel::Plugins::Model::RecordProtection::InstanceMethods
- Defined in:
- lib/model/record_protection.rb
Instance Method Summary collapse
- #before_destroy ⇒ Object
- #record_protected? ⇒ Boolean
- #set_record_protected ⇒ Object
- #set_record_protected! ⇒ Object
Instance Method Details
#before_destroy ⇒ Object
48 49 50 51 |
# File 'lib/model/record_protection.rb', line 48 def before_destroy super raise RecordProtectedError, self.class.[:raise_protected_message] if record_protected? end |
#record_protected? ⇒ Boolean
33 34 35 |
# File 'lib/model/record_protection.rb', line 33 def record_protected? self.class.[:enabled] ? send("#{self.class.[:column_protected]}") == 1 : false end |
#set_record_protected ⇒ Object
37 38 39 |
# File 'lib/model/record_protection.rb', line 37 def set_record_protected send("#{self.class.[:column_protected]}=", 1) if self.class.[: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.[:enabled] set_record_protected self.save end end |