Class: LittleGhost::Graph::State
- Inherits:
-
Object
- Object
- LittleGhost::Graph::State
- Defined in:
- lib/little_ghost/graph.rb
Overview
Immutable routing data passed to conditions and input mappers.
Instance Attribute Summary collapse
-
#branch_results ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#context ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#current ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#error ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#history ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#input ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#predecessors ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#previous ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#results ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
-
#step ⇒ Object
readonly
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
Instance Method Summary collapse
-
#initialize(input:, history:, context:, step:, current:, previous:, results:, predecessors: [], branch_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: [], branch_results: {}, error: nil) ⇒ State
Returns a new instance of State.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/little_ghost/graph.rb', line 53 def initialize(input:, history:, context:, step:, current:, previous:, results:, predecessors: [], branch_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 @branch_results = branch_results.dup.freeze @error = error freeze end |
Instance Attribute Details
#branch_results ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def branch_results @branch_results end |
#context ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def context @context end |
#current ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def current @current end |
#error ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def error @error end |
#history ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def history @history end |
#input ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def input @input end |
#predecessors ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def predecessors @predecessors end |
#previous ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def previous @previous end |
#results ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def results @results end |
#step ⇒ Object (readonly)
Original request data, current routing position, completed results, parallel predecessors, branch results, and the routed failure if any.
50 51 52 |
# File 'lib/little_ghost/graph.rb', line 50 def step @step end |
Instance Method Details
#previous_result ⇒ Object
Returns the immediately preceding result when present.
71 |
# File 'lib/little_ghost/graph.rb', line 71 def previous_result = previous && result(previous) |
#result(node_name) ⇒ Object
Returns a completed result by node name.
69 70 |
# File 'lib/little_ghost/graph.rb', line 69 def result(node_name) = results[node_name.to_sym] # Returns the immediately preceding result when present. |