class Laminar::Flow::Specification
Specification
for a flow (chained sequence of particles).
Attributes
first_step[RW]
steps[RW]
Public Class Methods
new(_args = {}, &spec)
click to toggle source
# File lib/laminar/flow/specification.rb, line 9 def initialize(_args = {}, &spec) @steps = {} instance_eval(&spec) if spec end
Public Instance Methods
after_each(*args, &block)
click to toggle source
# 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()
click to toggle source
# File lib/laminar/flow/specification.rb, line 48 def after_each_callbacks @after_each_callbacks ||= [] end
before_each(*args, &block)
click to toggle source
# 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()
click to toggle source
# File lib/laminar/flow/specification.rb, line 44 def before_each_callbacks @before_each_callbacks ||= [] end
context_must_have(*params)
click to toggle source
# File lib/laminar/flow/specification.rb, line 26 def context_must_have(*params) flow_params.concat(params.flatten) end
flow_params()
click to toggle source
# File lib/laminar/flow/specification.rb, line 30 def flow_params @flow_params ||= [] end
step(name, options = {}, &gotos)
click to toggle source
# File lib/laminar/flow/specification.rb, line 14 def step(name, options = {}, &gotos) step = add_step(name, options, &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
Private Instance Methods
add_step(name, options = {}, &gotos)
click to toggle source
# File lib/laminar/flow/specification.rb, line 54 def add_step(name, options = {}, &gotos) raise ArgumentError, "Step #{name} defined twice" if @steps.key?(name) step = Step.new(name, options, &gotos) @first_step ||= step.name @steps[step.name] = step end