Class: Workflow::Event::Conditions Private
- Inherits:
-
Object
- Object
- Workflow::Event::Conditions
- Defined in:
- lib/workflow/event.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Maintains a list of callback procs which are evaluted to determine if the transition on which they were defined is valid for an object in its current state. Borrowed from ActiveSupport::Callbacks See original source here
Instance Method Summary collapse
- #apply?(target) ⇒ Boolean private
-
#initialize(**options, &block) ⇒ Conditions
constructor
private
A new instance of Conditions.
- #inspect ⇒ Object private
Constructor Details
#initialize(**options, &block) ⇒ Conditions
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Conditions.
125 126 127 128 129 130 |
# File 'lib/workflow/event.rb', line 125 def initialize(**, &block) @if = Array([:if]) @unless = Array([:unless]) @if << block if block_given? @conditions_lambdas = conditions_lambdas end |
Instance Method Details
#apply?(target) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
136 137 138 |
# File 'lib/workflow/event.rb', line 136 def apply?(target) @conditions_lambdas.all? { |l| l.call(target) } end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
132 133 134 |
# File 'lib/workflow/event.rb', line 132 def inspect "if: #{@if}, unless: #{@unless}" end |