Class: Simplerubysteps::StateMachine

Inherits:
Object
  • Object
show all
Defined in:
lib/simplerubysteps.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStateMachine

Returns a new instance of StateMachine.



19
20
21
22
# File 'lib/simplerubysteps.rb', line 19

def initialize()
  @states = {}
  @kind = "STANDARD"
end

Instance Attribute Details

#kindObject

Returns the value of attribute kind.



17
18
19
# File 'lib/simplerubysteps.rb', line 17

def kind
  @kind
end

#start_atObject (readonly)

Returns the value of attribute start_at.



16
17
18
# File 'lib/simplerubysteps.rb', line 16

def start_at
  @start_at
end

#statesObject (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



24
25
26
27
28
29
30
31
# File 'lib/simplerubysteps.rb', line 24

def add(state)
  @start_at = state.name unless @start_at

  @states[state.name] = state
  state.state_machine = self

  state
end

#renderObject



33
34
35
36
37
38
# File 'lib/simplerubysteps.rb', line 33

def render
  {
    :StartAt => @start_at,
    :States => @states.map { |name, state| [name, state.render] }.to_h,
  }
end