Class: NextStation::State
- Inherits:
-
Object
- Object
- NextStation::State
- Extended by:
- Forwardable
- Defined in:
- lib/next_station/state.rb
Overview
Holds the mutable state during operation execution.
It wraps a data hash and provides access to params and context.
Instance Attribute Summary collapse
-
#context ⇒ Hash
readonly
The execution context.
-
#current_step ⇒ Symbol?
readonly
The name of the current step being executed.
-
#step_attempt ⇒ Integer
readonly
The attempt number of the current step.
Instance Method Summary collapse
-
#initialize(params = {}, context = {}, plugins = []) ⇒ State
constructor
A new instance of State.
-
#params ⇒ Hash
Returns the input parameters.
-
#set_current_step(value) ⇒ Object
Sets the name of the current step.
-
#set_step_attempt(value) ⇒ Object
Sets the current attempt number for the active step.
Constructor Details
#initialize(params = {}, context = {}, plugins = []) ⇒ State
Returns a new instance of State.
22 23 24 25 26 27 28 |
# File 'lib/next_station/state.rb', line 22 def initialize(params = {}, context = {}, plugins = []) @context = context.dup.freeze @data = { params: unwrap_params(params).dup } @step_attempt = 1 @current_step = nil extend_with_plugins(plugins) end |
Instance Attribute Details
#context ⇒ Hash (readonly)
Returns The execution context.
14 15 16 |
# File 'lib/next_station/state.rb', line 14 def context @context end |
#current_step ⇒ Symbol? (readonly)
Returns The name of the current step being executed.
18 19 20 |
# File 'lib/next_station/state.rb', line 18 def current_step @current_step end |
#step_attempt ⇒ Integer (readonly)
Returns The attempt number of the current step.
16 17 18 |
# File 'lib/next_station/state.rb', line 16 def step_attempt @step_attempt end |
Instance Method Details
#params ⇒ Hash
Returns the input parameters.
44 45 46 |
# File 'lib/next_station/state.rb', line 44 def params @data[:params] end |
#set_current_step(value) ⇒ Object
Sets the name of the current step.
38 39 40 |
# File 'lib/next_station/state.rb', line 38 def set_current_step(value) @current_step = value end |
#set_step_attempt(value) ⇒ Object
Sets the current attempt number for the active step.
32 33 34 |
# File 'lib/next_station/state.rb', line 32 def set_step_attempt(value) @step_attempt = value end |