Module: Protective::InstanceMethods
- Defined in:
- lib/protective.rb
Instance Method Summary collapse
-
#destruction_allowed? ⇒ Boolean
Returns true if this record may be destroyed or adds possible error messages to the #errors object otherwise.
-
#protected? ⇒ Boolean
Returns true if this record cannot be destroyed.
Instance Method Details
#destruction_allowed? ⇒ Boolean
Returns true if this record may be destroyed or adds possible error messages to the #errors object otherwise.
38 39 40 41 42 43 44 45 |
# File 'lib/protective.rb', line 38 def destruction_allowed? protect_if_methods.all? do |method, | unless allowed = protect_method_allows_destruction(method) errors.add(:base, ) if end allowed end end |
#protected? ⇒ Boolean
Returns true if this record cannot be destroyed.
30 31 32 33 34 |
# File 'lib/protective.rb', line 30 def protected? protect_if_methods.keys.any? do |method| !protect_method_allows_destruction(method) end end |