Skip to content

Instantly share code, notes, and snippets.

module Enumerable
def retrying(exception)
last = count
each_with_index do |el, index|
begin
return yield el
rescue exception
raise unless index + 1 < last
end
end