Class: FlowEngine::Definition
- Inherits:
-
Object
- Object
- FlowEngine::Definition
- Defined in:
- lib/flowengine/definition.rb
Overview
Immutable, versionable flow graph: maps step ids to Node objects and defines the entry point. Built by FlowEngine::DSL::FlowBuilder; consumed by Engine for navigation.
Instance Attribute Summary collapse
-
#introduction ⇒ Object
readonly
Returns the value of attribute introduction.
-
#start_step_id ⇒ Symbol
readonly
id of the first step in the flow.
-
#steps ⇒ Hash<Symbol, Node>
readonly
frozen map of step id => node (read-only).
Instance Method Summary collapse
-
#initialize(start_step_id:, nodes:, introduction: nil) ⇒ Definition
constructor
A new instance of Definition.
-
#start_step ⇒ Node
The node for the start step.
-
#step(id) ⇒ Node
The node for that step.
-
#step_ids ⇒ Array<Symbol>
All step ids in the definition.
Constructor Details
#initialize(start_step_id:, nodes:, introduction: nil) ⇒ Definition
Returns a new instance of Definition.
16 17 18 19 20 21 22 |
# File 'lib/flowengine/definition.rb', line 16 def initialize(start_step_id:, nodes:, introduction: nil) @start_step_id = start_step_id @steps = nodes.freeze @introduction = introduction validate! freeze end |
Instance Attribute Details
#introduction ⇒ Object (readonly)
Returns the value of attribute introduction.
10 11 12 |
# File 'lib/flowengine/definition.rb', line 10 def introduction @introduction end |
#start_step_id ⇒ Symbol (readonly)
id of the first step in the flow
9 10 11 |
# File 'lib/flowengine/definition.rb', line 9 def start_step_id @start_step_id end |
#steps ⇒ Hash<Symbol, Node> (readonly)
frozen map of step id => node (read-only)
9 10 11 |
# File 'lib/flowengine/definition.rb', line 9 def steps @steps end |
Instance Method Details
#start_step ⇒ Node
Returns the node for the start step.
25 26 27 |
# File 'lib/flowengine/definition.rb', line 25 def start_step step(start_step_id) end |
#step(id) ⇒ Node
Returns the node for that step.
32 33 34 |
# File 'lib/flowengine/definition.rb', line 32 def step(id) steps.fetch(id) { raise Errors::UnknownStepError, "Unknown step: #{id.inspect}" } end |
#step_ids ⇒ Array<Symbol>
Returns all step ids in the definition.
37 38 39 |
# File 'lib/flowengine/definition.rb', line 37 def step_ids steps.keys end |