Sha256: e45df1252dca79cee0c342bc0550b4daea191aebf318ec9407627de6c600d823
Contents?: true
Size: 436 Bytes
Versions: 1
Compression:
Stored size: 436 Bytes
Contents
# See README.md for usage explanations def retry_upto(max_retries = 1, opts = {}) yield rescue *(opts[:rescue] || Exception) attempt = attempt ? attempt+1 : 1 raise if (attempt == max_retries) if interval = opts[:interval] secs = interval.respond_to?(:call) ? interval.call(attempt) : interval sleep(secs) end retry end class Enumerator def retry(opts = {}, &blk) retry_upto(self.count, opts, &blk) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
retry_upto-1.2 | lib/retry_upto.rb |