Class: MethodDecorators::Retry
- Defined in:
- lib/method_decorators/retry.rb
Instance Method Summary collapse
- #call(orig, this, *args, &blk) ⇒ Object
-
#initialize(max) ⇒ Retry
constructor
A new instance of Retry.
Methods inherited from Decorator
Constructor Details
#initialize(max) ⇒ Retry
Returns a new instance of Retry.
5 6 7 |
# File 'lib/method_decorators/retry.rb', line 5 def initialize(max) @max = max end |
Instance Method Details
#call(orig, this, *args, &blk) ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/method_decorators/retry.rb', line 9 def call(orig, this, *args, &blk) attempts = 0 begin attempts += 1 orig.call(*args, &blk) rescue retry if attempts < @max raise end end |