Module: Laminar::Flow
- Defined in:
- lib/laminar/flow.rb,
lib/laminar/flow/step.rb,
lib/laminar/flow/branch.rb,
lib/laminar/flow/flow_error.rb,
lib/laminar/flow/specification.rb,
lib/laminar/flow/options_validator.rb
Overview
Implements a DSL for defining a chain of Particles. Each step (particle) contributes to an overall answer/outcome via a shared context.
Simple branching and looping is supported via conditional jumps.
The most basic flow is a simple set of steps executed sequentially. Each step symbol names a class that includes Laminar::Particle. The call method specifies keyword arguments that the flow uses to determine which parts of the execution context to pass to the step.
By default, the flow uses the step label as the implementation particle name. You can use the class directive to specify an alternate class name. This can be a String or Symbol. Very useful when your particles are organised into modules. Branching is implemented via the goto directive. These directives are evaluated immediately following the execution of a step.
In the previous example, execution will pass to last_step is the supplied method should_i? (on the flow instance) returns true. If no branch satisfies its conditions, execution will fall through to the next step.
A step can have muluple goto directives; the flow will take the first branch that it finds that satisfies its specified condition (if any). You can use the special goto tag :endflow to conditionally teriminate the flow.
Defined Under Namespace
Modules: ClassMethods, InstanceMethods, OptionsValidator Classes: Branch, FlowError, Specification, Step
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/laminar/flow.rb', line 78 def self.included(base) base.class_eval do include Particle extend ClassMethods include InstanceMethods end end |