Class: EventMachine::Scenario::AdNauseum

Inherits:
Object
  • Object
show all
Includes:
EM::Deferrable
Defined in:
lib/scenario/latin.rb

Overview

Until sick. Act again and again, until criteria

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ AdNauseum

Returns a new instance of AdNauseum.



149
150
151
152
# File 'lib/scenario/latin.rb', line 149

def initialize &block
  @loop = block
  self
end

Instance Method Details

#finally(&block) ⇒ Object



159
160
161
162
163
# File 'lib/scenario/latin.rb', line 159

def finally &block
  self.callback &block
  @loop.call( Proc.new { nextStep })
  self
end

#nextStepObject



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

def nextStep
  if @criteria.call
    self.succeed
  else
    @loop.call( Proc.new { nextStep })
  end
end

#until(&block) ⇒ Object



154
155
156
157
# File 'lib/scenario/latin.rb', line 154

def until &block
  @criteria = block
  self
end