Class: Simplerubysteps::StateMachine

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStateMachine

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

#kindObject

Returns the value of attribute kind.



12
13
14
# File 'lib/simplerubysteps/model.rb', line 12

def kind
  @kind
end

#start_atObject (readonly)

Returns the value of attribute start_at.



11
12
13
# File 'lib/simplerubysteps/model.rb', line 11

def start_at
  @start_at
end

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

#renderObject



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