Module: Kernel
- Defined in:
- lib/gems/cachetastic-2.1.2/lib/cachetastic/ruby_extensions/kernel.rb
Overview
:nodoc:
Instance Method Summary collapse
Instance Method Details
#retryable(options = {}, &block) ⇒ Object
:nodoc:
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/gems/cachetastic-2.1.2/lib/cachetastic/ruby_extensions/kernel.rb', line 3 def retryable( = {}, &block) # :nodoc: opts = { :tries => 1, :on => Exception }.merge() retries = opts[:tries] retry_exceptions = [opts[:on]].flatten x = %{ begin return yield rescue #{retry_exceptions.join(", ")} => e retries -= 1 if retries > 0 retry else raise e end end } eval(x, &block) end |