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.



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

def initialize()
  @states = {}
end

Instance Attribute Details

#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



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

#renderObject



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