Module: Retry
- Included in:
- FlexCommerce::PaypalExpress::Auth
- Defined in:
- lib/retry.rb
Constant Summary collapse
- DEFAULT_MAX_NO_OF_RETRIES =
2
- DEFAULT_RESCUE_ERRORS =
StandardError
Class Method Summary collapse
- .call(no_of_retries: DEFAULT_MAX_NO_OF_RETRIES, rescue_errors: DEFAULT_RESCUE_ERRORS, &blk) ⇒ Object
Class Method Details
.call(no_of_retries: DEFAULT_MAX_NO_OF_RETRIES, rescue_errors: DEFAULT_RESCUE_ERRORS, &blk) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/retry.rb', line 7 def self.call(no_of_retries: DEFAULT_MAX_NO_OF_RETRIES, rescue_errors: DEFAULT_RESCUE_ERRORS, &blk) total_attempts = 0 begin blk.call rescue rescue_errors => ex total_attempts += 1 retry if total_attempts < no_of_retries ensure if total_attempts == no_of_retries return end end end |