Skip to content

Instantly share code, notes, and snippets.

@ginzarichard
Created August 1, 2011 18:25
Show Gist options
  • Save ginzarichard/1118693 to your computer and use it in GitHub Desktop.
Save ginzarichard/1118693 to your computer and use it in GitHub Desktop.
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
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment