Class: StepMachine::Runner::FailureTreatment

Inherits:
Object
  • Object
show all
Defined in:
lib/step_machine/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner, block, options) ⇒ FailureTreatment

Returns a new instance of FailureTreatment.



159
160
161
162
163
# File 'lib/step_machine/runner.rb', line 159

def initialize(runner, block, options)
  @runner = runner
  @block = block
  @options = options
end

Instance Attribute Details

#stepObject

Returns the value of attribute step.



157
158
159
# File 'lib/step_machine/runner.rb', line 157

def step
  @step
end

Instance Method Details

#continueObject



184
185
186
# File 'lib/step_machine/runner.rb', line 184

def continue
  go_to(@step.next.name)
end

#go_to(step_name) ⇒ Object



173
174
175
176
# File 'lib/step_machine/runner.rb', line 173

def go_to(step_name)        
  @runner.next_step = @runner.step(step_name)
  @runner.continue = true
end

#repeatObject



178
179
180
181
182
# File 'lib/step_machine/runner.rb', line 178

def repeat
  go_to(@step.name)
  @runner.repeat_what = :step
  self
end

#restartObject



188
189
190
191
192
# File 'lib/step_machine/runner.rb', line 188

def restart
  go_to(@runner.first_step.name)
  @runner.repeat_what = :process
  self
end

#times(number) ⇒ Object



194
195
196
# File 'lib/step_machine/runner.rb', line 194

def times(number)
  @runner.times_to_repeat = number - 1
end

#treat(step) ⇒ Object



165
166
167
168
169
170
171
# File 'lib/step_machine/runner.rb', line 165

def treat(step)       
  return if @options.has_key?(:only) && !@options[:only].include?(step.name)
   return if @options.has_key?(:except) && @options[:except].include?(step.name)
   @step = step

   @block.call(self)
end