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.



21
22
23
24
# File 'lib/simplerubysteps/model.rb', line 21

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

Instance Attribute Details

#kindObject

Returns the value of attribute kind.



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

def kind
  @kind
end

#start_atObject (readonly)

Returns the value of attribute start_at.



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

def start_at
  @start_at
end

#statesObject (readonly)

Returns the value of attribute states.



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

def states
  @states
end

Instance Method Details

#add(state) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/simplerubysteps/model.rb', line 26

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

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

  state
end

#cloudformation_configObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/simplerubysteps/model.rb', line 35

def cloudformation_config
  data = []
  states.each do |name, state|
    if state.is_a? Task or state.is_a? Callback
      data.push({
        env: {
          task: name,
        },
        iam_permissions: state.iam_permissions,
        queue: ((state.is_a? Callback) ? state.queue : nil),
      })
    end
  end
  data
end

#renderObject



51
52
53
54
55
56
# File 'lib/simplerubysteps/model.rb', line 51

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