Module: God::Conditions::ConditionHelper

Included in:
HttpResponseCode, Lambda
Defined in:
lib/god/conditions/condition_helper.rb

Instance Method Summary collapse

Instance Method Details

#timeline_test(res) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/god/conditions/condition_helper.rb', line 6

def timeline_test(res)
  @timeline << res
  history = " - SUCCESS RATE: [#{@timeline.select { |x| x }.size}/#{@timeline.length}]"
  if @timeline.select { |x| x }.size >= self.times[0]
    self.info = " PASSED #{history}"
    return true
  elsif @timeline.select { |x| !x }.size > self.times[1] - self.times[0]
    self.info = " FAILED #{history}"
    return false
  else
    self.info = "history too short: #{history}"
    return nil # do not trigger a transition
  end
end