module Protective::ClassMethods
Public Instance Methods
protect_if(method, message = nil)
click to toggle source
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.
# File lib/protective.rb, line 14 def protect_if(method, message = 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] = message end