Class: Simplerubysteps::StateMachine
- Inherits:
-
Object
- Object
- Simplerubysteps::StateMachine
- Defined in:
- lib/simplerubysteps.rb
Instance Attribute Summary collapse
-
#start_at ⇒ Object
readonly
Returns the value of attribute start_at.
-
#states ⇒ Object
readonly
Returns the value of attribute states.
Instance Method Summary collapse
- #add(state) ⇒ Object
-
#initialize ⇒ StateMachine
constructor
A new instance of StateMachine.
- #render ⇒ Object
Constructor Details
#initialize ⇒ StateMachine
Returns a new instance of StateMachine.
18 19 20 |
# File 'lib/simplerubysteps.rb', line 18 def initialize() @states = {} end |
Instance Attribute Details
#start_at ⇒ Object (readonly)
Returns the value of attribute start_at.
16 17 18 |
# File 'lib/simplerubysteps.rb', line 16 def start_at @start_at end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
15 16 17 |
# File 'lib/simplerubysteps.rb', line 15 def states @states end |
Instance Method Details
#add(state) ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/simplerubysteps.rb', line 22 def add(state) @start_at = state.name unless @start_at @states[state.name] = state state.state_machine = self state end |
#render ⇒ Object
31 32 33 34 35 36 |
# File 'lib/simplerubysteps.rb', line 31 def render { :StartAt => @start_at, :States => @states.map { |name, state| [name, state.render] }.to_h, } end |