Sha256: 89da56b5c7856cbaddf0e94b7f2f8b37bcbdcaa0d7e1d6da0830fe011c3dd455

Contents?: true

Size: 337 Bytes

Versions: 17

Compression:

Stored size: 337 Bytes

Contents

module Sym
  module Extensions
    module WithRetry

      def with_retry(retries: 3, fail_block: nil, &block)
        attempts = 0
        yield if block_given?
      rescue StandardError => e
        raise(e) if attempts >= retries
        fail_block.call if fail_block
        attempts += 1
        retry
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
sym-2.8.5 lib/sym/extensions/with_retry.rb
sym-2.8.4 lib/sym/extensions/with_retry.rb
sym-2.8.2 lib/sym/extensions/with_retry.rb
sym-2.8.1 lib/sym/extensions/with_retry.rb
sym-2.8.0 lib/sym/extensions/with_retry.rb
sym-2.7.0 lib/sym/extensions/with_retry.rb
sym-2.6.3 lib/sym/extensions/with_retry.rb
sym-2.6.2 lib/sym/extensions/with_retry.rb
sym-2.6.1 lib/sym/extensions/with_retry.rb
sym-2.6.0 lib/sym/extensions/with_retry.rb
sym-2.5.3 lib/sym/extensions/with_retry.rb
sym-2.5.1 lib/sym/extensions/with_retry.rb
sym-2.5.0 lib/sym/extensions/with_retry.rb
sym-2.4.3 lib/sym/extensions/with_retry.rb
sym-2.3.0 lib/sym/extensions/with_retry.rb
sym-2.2.1 lib/sym/extensions/with_retry.rb
sym-2.2.0 lib/sym/extensions/with_retry.rb