Skip to content

Instantly share code, notes, and snippets.

@bcobb
Created September 4, 2012 22:47
Show Gist options
  • Save bcobb/3627615 to your computer and use it in GitHub Desktop.
Save bcobb/3627615 to your computer and use it in GitHub Desktop.
# at_most(5.times) do
# some_volatile_operation
# end
def at_most(enum)
begin
yield
rescue => e
can_retry = enum.next rescue false
if can_retry
retry
else
raise e
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment