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
- #cloudformation_config ⇒ Object
-
#initialize ⇒ StateMachine
constructor
A new instance of StateMachine.
- #render ⇒ Object
Constructor Details
#initialize ⇒ StateMachine
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
#kind ⇒ Object
Returns the value of attribute kind.
19 20 21 |
# File 'lib/simplerubysteps/model.rb', line 19 def kind @kind end |
#start_at ⇒ Object (readonly)
Returns the value of attribute start_at.
18 19 20 |
# File 'lib/simplerubysteps/model.rb', line 18 def start_at @start_at end |
#states ⇒ Object (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_config ⇒ Object
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., queue: ((state.is_a? Callback) ? state.queue : nil), }) end end data end |
#render ⇒ Object
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 |