Module: Retryable

Extended by:
Retryable
Included in:
Retryable
Defined in:
lib/hostelify/hostelify.rb

Instance Method Summary collapse

Instance Method Details

#try(times = 1, options = {}, &block) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/hostelify/hostelify.rb', line 53

def try times = 1, options = {}, &block
  val = yield
rescue options[:on] || Exception
  retry if (times -= 1) > 0
else
  val
end