Sha256: 1526feaf04eefebcbdfd5ae64cb292fb024d93b76f3c4625927601012bf41e1d
Contents?: true
Size: 534 Bytes
Versions: 1
Compression:
Stored size: 534 Bytes
Contents
# See README.md for usage explanations def retry_upto(max_retries = 1, options = {}) yield rescue *(options[:rescue] || Exception) raise if (max_retries -= 1) == 0 sleep(options[:interval] || 0) if options[:growth].respond_to?('*') options[:interval] = options[:interval] * options[:growth] elsif options[:growth].respond_to?(:call) options[:interval] = options[:growth].call(options[:interval]) end retry end class Enumerator def retry(options = {}, &blk) retry_upto(self.count, options, &blk) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
retry_upto-1.1 | lib/retry_upto.rb |