Class: RunLoop::RetryOpts

Inherits:
Object
  • Object
show all
Defined in:
lib/run_loop/patches/retriable.rb

Overview

A class to bridge the gap between retriable 1.x and 2.0.

Class Method Summary collapse

Class Method Details

.tries_and_interval(tries, interval, other_retry_options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/run_loop/patches/retriable.rb', line 6

def self.tries_and_interval(tries, interval, other_retry_options={})
  retriable_version = RunLoop::Version.new(Retriable::VERSION)

  if other_retry_options[:tries]
    raise RuntimeError, ':tries is not a valid key for other_retry_options'
  elsif other_retry_options[:interval]
    raise RuntimeError, ':interval is not a valid key for other_retry_options'
  elsif other_retry_options[:intervals]
    raise RuntimeError, ':intervals is not a valid key for other_retry_options'
  end

  if retriable_version >= RunLoop::Version.new('2.0.0')
    other_retry_options.merge({:intervals => Array.new(tries, interval)})
  else
    other_retry_options.merge({:tries => tries, :interval => interval})
  end
end