Module: ActsAsApprovable::Model::DestroyInstanceMethods
- Defined in:
- lib/acts_as_approvable/model/destroy_instance_methods.rb
Overview
Instance methods that apply to the ‘:destroy` event specifically.
Instance Method Summary collapse
-
#destroy ⇒ Object
Add a ‘:destrory` approval event to the queue if approvals are enabled, otherwise destroy the record.
-
#destroy_approvals(all = true) ⇒ Approval
Retrieve approval records for the destruction event.
-
#pending_destruction? ⇒ Boolean
Returns true if there are any pending ‘:destroy` event approvals.
Instance Method Details
#destroy ⇒ Object
Add a ‘:destrory` approval event to the queue if approvals are enabled, otherwise destroy the record.
24 25 26 |
# File 'lib/acts_as_approvable/model/destroy_instance_methods.rb', line 24 def destroy approvable_destroy? ? request_destruction : super end |
#destroy_approvals(all = true) ⇒ Approval
Retrieve approval records for the destruction event.
11 12 13 |
# File 'lib/acts_as_approvable/model/destroy_instance_methods.rb', line 11 def destroy_approvals(all = true) all ? approvals.find_all_by_event('destroy') : approvals.find_all_by_event_and_state('destroy', 0) end |
#pending_destruction? ⇒ Boolean
Returns true if there are any pending ‘:destroy` event approvals
17 18 19 |
# File 'lib/acts_as_approvable/model/destroy_instance_methods.rb', line 17 def pending_destruction? not destroy_approvals(false).empty? end |