Class: Laminar::Flow::Specification
- Inherits:
-
Object
- Object
- Laminar::Flow::Specification
- Defined in:
- lib/laminar/flow/specification.rb
Overview
Specification for a flow (chained sequence of particles).
Instance Attribute Summary collapse
-
#first_step ⇒ Object
Returns the value of attribute first_step.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #after_each(*args, &block) ⇒ Object
- #after_each_callbacks ⇒ Object
- #before_each(*args, &block) ⇒ Object
- #before_each_callbacks ⇒ Object
- #context_must_have(*params) ⇒ Object
- #flow_params ⇒ Object
-
#initialize(_args = {}, &spec) ⇒ Specification
constructor
A new instance of Specification.
- #step(name, options = {}, &gotos) ⇒ Object
Constructor Details
#initialize(_args = {}, &spec) ⇒ Specification
Returns a new instance of Specification.
9 10 11 12 |
# File 'lib/laminar/flow/specification.rb', line 9 def initialize(_args = {}, &spec) @steps = {} instance_eval(&spec) if spec end |
Instance Attribute Details
#first_step ⇒ Object
Returns the value of attribute first_step.
7 8 9 |
# File 'lib/laminar/flow/specification.rb', line 7 def first_step @first_step end |
#steps ⇒ Object
Returns the value of attribute steps.
7 8 9 |
# File 'lib/laminar/flow/specification.rb', line 7 def steps @steps end |
Instance Method Details
#after_each(*args, &block) ⇒ Object
39 40 41 42 |
# File 'lib/laminar/flow/specification.rb', line 39 def after_each(*args, &block) after_each_callbacks.concat(args) after_each_callbacks << block if block end |
#after_each_callbacks ⇒ Object
48 49 50 |
# File 'lib/laminar/flow/specification.rb', line 48 def after_each_callbacks @after_each_callbacks ||= [] end |
#before_each(*args, &block) ⇒ Object
34 35 36 37 |
# File 'lib/laminar/flow/specification.rb', line 34 def before_each(*args, &block) before_each_callbacks.concat(args) before_each_callbacks << block if block end |
#before_each_callbacks ⇒ Object
44 45 46 |
# File 'lib/laminar/flow/specification.rb', line 44 def before_each_callbacks @before_each_callbacks ||= [] end |
#context_must_have(*params) ⇒ Object
26 27 28 |
# File 'lib/laminar/flow/specification.rb', line 26 def context_must_have(*params) flow_params.concat(params.flatten) end |
#flow_params ⇒ Object
30 31 32 |
# File 'lib/laminar/flow/specification.rb', line 30 def flow_params @flow_params ||= [] end |
#step(name, options = {}, &gotos) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/laminar/flow/specification.rb', line 14 def step(name, = {}, &gotos) step = add_step(name, , &gotos) # backport a default next step onto the previous step to point to # the current one, unless this is the first step. Allows for simple # case where execution just falls through to the next step where they # haven't specified any explicit branching or none of the branch # conditions get met. @prev_step&.branch(step.name) @prev_step = step end |