Module: Protective::ClassMethods
- Defined in:
- lib/protective.rb
Instance Method Summary collapse
-
#protect_if(method, message = nil) ⇒ Object
Protects a record from being destroyed if the passed method evaluates to #present? upon destruction.
Instance Method Details
#protect_if(method, message = nil) ⇒ Object
Protects a record from being destroyed if the passed method evaluates to #present? upon destruction. If a messag is given, it is added to the corresponding #errors object.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/protective.rb', line 14 def protect_if(method, = nil) unless self < InstanceMethods class_attribute :protect_if_methods self.protect_if_methods = {} before_destroy :destruction_allowed? send :include, InstanceMethods end protect_if_methods[method] = end |