Class: LittleGhost::Graph::State
- Inherits:
-
Object
- Object
- LittleGhost::Graph::State
- Defined in:
- lib/little_ghost/graph.rb
Overview
Read-only routing data passed to conditions and input mappers.
results contains every completed node result. incoming_results
contains only the immediate predecessors supplying the current node.
previous and #previous_result are present for a single predecessor;
predecessors preserves declaration order for fan-in execution.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
A frozen copy of application context available to the condition or mapper.
-
#current ⇒ Object
readonly
The source node for a condition, or destination node for an input mapper.
-
#error ⇒ Object
readonly
A frozen copy of the routed exception available to an error-edge mapper.
-
#history ⇒ Object
readonly
A frozen copy of caller history available to the condition or mapper.
-
#incoming_results ⇒ Object
readonly
Frozen copies of immediate predecessor RunResults keyed by node name.
-
#input ⇒ Object
readonly
A copied Message containing the original request.
-
#predecessors ⇒ Object
readonly
The immediate predecessor names in declaration order.
-
#previous ⇒ Object
readonly
The predecessor name when exactly one result supplies the current node.
-
#results ⇒ Object
readonly
Frozen copies of completed RunResults keyed by node name.
-
#step ⇒ Object
readonly
The one-based execution count assigned to the current node.
Instance Method Summary collapse
-
#initialize(input:, history:, context:, step:, current:, previous:, results:, predecessors: [], incoming_results: {}, error: nil) ⇒ State
constructor
A new instance of State.
-
#previous_result ⇒ Object
Returns the immediately preceding result when present.
-
#result(node_name) ⇒ Object
Returns a completed result by node name.
Constructor Details
#initialize(input:, history:, context:, step:, current:, previous:, results:, predecessors: [], incoming_results: {}, error: nil) ⇒ State
Returns a new instance of State.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/little_ghost/graph.rb', line 85 def initialize(input:, history:, context:, step:, current:, previous:, results:, predecessors: [], incoming_results: {}, error: nil) # :nodoc: @input = input @history = history @context = context @step = step @current = current @previous = previous @predecessors = Array(predecessors).map(&:to_sym).freeze @results = results.dup.freeze @incoming_results = incoming_results.dup.freeze @error = error freeze end |
Instance Attribute Details
#context ⇒ Object (readonly)
A frozen copy of application context available to the condition or mapper.
69 70 71 |
# File 'lib/little_ghost/graph.rb', line 69 def context @context end |
#current ⇒ Object (readonly)
The source node for a condition, or destination node for an input mapper.
73 74 75 |
# File 'lib/little_ghost/graph.rb', line 73 def current @current end |
#error ⇒ Object (readonly)
A frozen copy of the routed exception available to an error-edge mapper.
83 84 85 |
# File 'lib/little_ghost/graph.rb', line 83 def error @error end |
#history ⇒ Object (readonly)
A frozen copy of caller history available to the condition or mapper.
67 68 69 |
# File 'lib/little_ghost/graph.rb', line 67 def history @history end |
#incoming_results ⇒ Object (readonly)
Frozen copies of immediate predecessor RunResults keyed by node name.
81 82 83 |
# File 'lib/little_ghost/graph.rb', line 81 def incoming_results @incoming_results end |
#input ⇒ Object (readonly)
A copied Message containing the original request.
65 66 67 |
# File 'lib/little_ghost/graph.rb', line 65 def input @input end |
#predecessors ⇒ Object (readonly)
The immediate predecessor names in declaration order.
77 78 79 |
# File 'lib/little_ghost/graph.rb', line 77 def predecessors @predecessors end |
#previous ⇒ Object (readonly)
The predecessor name when exactly one result supplies the current node.
75 76 77 |
# File 'lib/little_ghost/graph.rb', line 75 def previous @previous end |
#results ⇒ Object (readonly)
Frozen copies of completed RunResults keyed by node name.
79 80 81 |
# File 'lib/little_ghost/graph.rb', line 79 def results @results end |
#step ⇒ Object (readonly)
The one-based execution count assigned to the current node.
71 72 73 |
# File 'lib/little_ghost/graph.rb', line 71 def step @step end |
Instance Method Details
#previous_result ⇒ Object
Returns the immediately preceding result when present.
103 |
# File 'lib/little_ghost/graph.rb', line 103 def previous_result = previous && result(previous) |
#result(node_name) ⇒ Object
Returns a completed result by node name.
101 102 |
# File 'lib/little_ghost/graph.rb', line 101 def result(node_name) = results[node_name.to_sym] # Returns the immediately preceding result when present. |