Module: PatientlyTry

Defined in:
lib/patiently_try.rb,
lib/patiently_try/version.rb

Constant Summary collapse

VERSION =
"0.2.2"

Instance Method Summary collapse

Instance Method Details

#patiently_try(opts = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/patiently_try.rb', line 4

def patiently_try(opts = {})
  opts = _parse_opts(opts)
  try  = 0

  begin
    yield
  rescue *(opts[:catch]) => e
    try += 1

    _rescue_or_raise(e, try, opts)

    _wait(opts[:wait])
    retry
  end
end