lib/run_loop/patches/retriable.rb in run_loop-1.3.1 vs lib/run_loop/patches/retriable.rb in run_loop-1.3.2
- old
+ new
@@ -1,6 +1,7 @@
require 'retriable'
+require 'retriable/version'
module RunLoop
# 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={})
@@ -17,8 +18,28 @@
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
+ end
+end
+
+# Only in retriable 1.4.0
+unless Retriable.public_instance_methods.include?(:retriable)
+ require 'retriable/retry'
+ module Retriable
+ extend self
+
+ def retriable(opts = {}, &block)
+ raise LocalJumpError unless block_given?
+
+ Retry.new do |r|
+ r.tries = opts[:tries] if opts[:tries]
+ r.on = opts[:on] if opts[:on]
+ r.interval = opts[:interval] if opts[:interval]
+ r.timeout = opts[:timeout] if opts[:timeout]
+ r.on_retry = opts[:on_retry] if opts[:on_retry]
+ end.perform(&block)
end
end
end