Class: ExpRetry
- Inherits:
-
Object
- Object
- ExpRetry
- Defined in:
- lib/exp_retry.rb
Overview
Exponential backoff retry wrapper
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(retries: 3, exception: StandardError, verbose: false) ⇒ ExpRetry
constructor
A new instance of ExpRetry.
Constructor Details
#initialize(retries: 3, exception: StandardError, verbose: false) ⇒ ExpRetry
Returns a new instance of ExpRetry.
9 10 11 12 13 |
# File 'lib/exp_retry.rb', line 9 def initialize(retries: 3, exception: StandardError, verbose: false) @retries = retries @exception = exception @verbose = verbose end |
Class Method Details
.for(retries: 3, exception: StandardError, verbose: false) ⇒ Object
5 6 7 |
# File 'lib/exp_retry.rb', line 5 def self.for(retries: 3, exception: StandardError, verbose: false) new(retries: retries, exception: exception, verbose: verbose).call { yield } end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 |
# File 'lib/exp_retry.rb', line 15 def call yield if block_given? rescue *@exception => e check(e) retry end |