Module: ActsAsApprovable::Model::ClassMethods
- Defined in:
- lib/acts_as_approvable/model/class_methods.rb
Overview
Class methods available after acts_as_approvable has been called
Instance Method Summary collapse
-
#approvable_fields ⇒ Object
Returns a list of fields that require approval.
-
#approvable_on?(event) ⇒ Boolean
Returns true if the model is configured to use the approval queue on the given event (‘:create` or `:update`).
- #approvals_disabled? ⇒ Boolean
-
#approvals_enabled? ⇒ Boolean
Returns true if the approval queue is active at both the local and global level.
-
#approvals_off ⇒ Object
Disable the approval queue for this model.
-
#approvals_on ⇒ Object
Enable the approval queue for this model.
- #approvals_on? ⇒ Boolean
- #global_approvals_on? ⇒ Boolean
-
#without_approval(&block) ⇒ Object
Execute a code block while the approval queue is temporarily disabled.
Instance Method Details
#approvable_fields ⇒ Object
Returns a list of fields that require approval.
46 47 48 49 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 46 def approvable_fields return self.approvable_only unless self.approvable_only.empty? column_names - self.approvable_ignore end |
#approvable_on?(event) ⇒ Boolean
Returns true if the model is configured to use the approval queue on the given event (‘:create` or `:update`).
40 41 42 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 40 def approvable_on?(event) self.approvable_on.include?(event) end |
#approvals_disabled? ⇒ Boolean
13 14 15 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 13 def approvals_disabled? not approvals_enabled? end |
#approvals_enabled? ⇒ Boolean
Returns true if the approval queue is active at both the local and global level. Note that the global level supercedes the local level.
9 10 11 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 9 def approvals_enabled? global_approvals_on? and approvals_on? end |
#approvals_off ⇒ Object
Disable the approval queue for this model.
25 26 27 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 25 def approvals_off self.approvals_disabled = true end |
#approvals_on ⇒ Object
Enable the approval queue for this model.
19 20 21 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 19 def approvals_on self.approvals_disabled = false end |
#approvals_on? ⇒ Boolean
29 30 31 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 29 def approvals_on? not self.approvals_disabled end |
#global_approvals_on? ⇒ Boolean
33 34 35 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 33 def global_approvals_on? ActsAsApprovable.enabled? end |
#without_approval(&block) ⇒ Object
Execute a code block while the approval queue is temporarily disabled. The queue state will be returned to it’s previous value, either on or off.
54 55 56 57 58 59 60 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 54 def without_approval(&block) enable = self.approvals_on? approvals_off yield(self) ensure approvals_on if enable end |