Sha256: e51e7004ed8d3311882dee512cf68c238bec2734f52f866d73866b6663238414

Contents?: true

Size: 361 Bytes

Versions: 1

Compression:

Stored size: 361 Bytes

Contents

require 'tries/version'

class Integer
  def tries(options = {}, &block)
    attempts          = self
    exception_classes = Array(options[:on] || StandardError)
    delay             = options[:delay]

    begin
      return yield
    rescue *exception_classes
      Kernel.sleep delay if delay
      retry if (attempts -= 1) > 0
    end

    yield
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tries-0.1.0 lib/tries.rb