Sha256: 6f443dfdd6ac4d4611e159fb1dff0c06c3145b06a10f955a7844bec9bdb4a550

Contents?: true

Size: 913 Bytes

Versions: 7

Compression:

Stored size: 913 Bytes

Contents

require 'retriable'
require 'retriable/version'

module Luffa
  # A class to bridge the gap between retriable 1.x and 2.0.
  class RetryOpts
    def self.tries_and_interval(tries, interval, other_retry_options={})
      retriable_version = Luffa::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 >= Luffa::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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
luffa-2.1.0 lib/luffa/patches/retriable.rb
luffa-2.0.0 lib/luffa/patches/retriable.rb
luffa-1.1.0 lib/luffa/patches/retriable.rb
luffa-1.0.7 lib/luffa/patches/retriable.rb
luffa-1.0.6 lib/luffa/patches/retriable.rb
luffa-1.0.5 lib/luffa/patches/retriable.rb
luffa-1.0.4 lib/luffa/patches/retriable.rb