Module: Sym::Extensions::WithRetry
- Included in:
- App::Password::Cache
- Defined in:
- lib/sym/extensions/with_retry.rb
Instance Method Summary collapse
Instance Method Details
#with_retry(retries: 3, fail_block: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/sym/extensions/with_retry.rb', line 5 def with_retry(retries: 3, fail_block: nil) attempts = 0 yield if block_given? rescue StandardError => e raise(e) if attempts >= retries fail_block.call if fail_block attempts += 1 retry end |