Class: Simplerubysteps::Branch

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

Overview

FIXME refactor statemachine code dupduplicate

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBranch

Returns a new instance of Branch.



162
163
164
# File 'lib/simplerubysteps/model.rb', line 162

def initialize()
  @states = {}
end

Instance Attribute Details

#start_atObject (readonly)

Returns the value of attribute start_at.



160
161
162
# File 'lib/simplerubysteps/model.rb', line 160

def start_at
  @start_at
end

#statesObject (readonly)

Returns the value of attribute states.



159
160
161
# File 'lib/simplerubysteps/model.rb', line 159

def states
  @states
end

Instance Method Details

#add(state) ⇒ Object



166
167
168
169
170
171
172
173
# File 'lib/simplerubysteps/model.rb', line 166

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

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

  state
end

#renderObject



175
176
177
178
179
180
# File 'lib/simplerubysteps/model.rb', line 175

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