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)
-
- (Object) approvable_fields
Returns a list of fields that require approval.
-
- (Boolean) approvable_on?(event)
Returns true if the model is configured to use the approval queue on the given event (`:create` or `:update`).
- - (Boolean) approvals_disabled?
-
- (Boolean) approvals_enabled?
Returns true if the approval queue is active at both the local and global level.
-
- (Object) approvals_off
Disable the approval queue for this model.
-
- (Object) approvals_on
Enable the approval queue for this model.
- - (Boolean) approvals_on?
- - (Boolean) global_approvals_on?
-
- (Object) without_approval(&block)
Execute a code block while the approval queue is temporarily disabled.
Instance Method Details
- (Object) approvable_fields
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 |
- (Boolean) approvable_on?(event)
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 |
- (Boolean) approvals_disabled?
13 14 15 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 13 def approvals_disabled? not approvals_enabled? end |
- (Boolean) approvals_enabled?
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 |
- (Object) approvals_off
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 |
- (Object) approvals_on
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 |
- (Boolean) approvals_on?
29 30 31 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 29 def approvals_on? not self.approvals_disabled end |
- (Boolean) global_approvals_on?
33 34 35 |
# File 'lib/acts_as_approvable/model/class_methods.rb', line 33 def global_approvals_on? ActsAsApprovable.enabled? end |
- (Object) without_approval(&block)
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 |