Class: Simplerubysteps::StateMachine
- Inherits:
-
Object
- Object
- Simplerubysteps::StateMachine
- Defined in:
- lib/simplerubysteps/model.rb
Instance Attribute Summary collapse
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#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.
14 15 16 17 |
# File 'lib/simplerubysteps/model.rb', line 14 def initialize() @states = {} @kind = "STANDARD" end |
Instance Attribute Details
#kind ⇒ Object
Returns the value of attribute kind.
12 13 14 |
# File 'lib/simplerubysteps/model.rb', line 12 def kind @kind end |
#start_at ⇒ Object (readonly)
Returns the value of attribute start_at.
11 12 13 |
# File 'lib/simplerubysteps/model.rb', line 11 def start_at @start_at end |
#states ⇒ Object (readonly)
Returns the value of attribute states.
10 11 12 |
# File 'lib/simplerubysteps/model.rb', line 10 def states @states end |
Instance Method Details
#add(state) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/simplerubysteps/model.rb', line 19 def add(state) @start_at = state.name unless @start_at @states[state.name] = state state.state_machine = self state end |
#render ⇒ Object
28 29 30 31 32 33 |
# File 'lib/simplerubysteps/model.rb', line 28 def render { :StartAt => @start_at, :States => @states.map { |name, state| [name, state.render] }.to_h, } end |