Skip to content

Commit

Permalink
Fix hound
Browse files Browse the repository at this point in the history
  • Loading branch information
ermaker committed Aug 10, 2016
1 parent 012cdee commit 97dfce2
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/cool/retriable.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
module Cool
# Retriable
module Retriable
def retry_(new_method, on: StandardError, times: 3, &condition) # rubocop:disable Metrics/MethodLength, Metrics/LineLength
condition ||= ->(*) { false }
def retry_(new_method, on: StandardError, times: 3) # rubocop:disable Metrics/MethodLength, Metrics/LineLength
orig_method = "__retry_orig_#{new_method}".to_sym
alias_method orig_method, new_method
define_method(new_method) do |*args, &block|
Expand All @@ -13,7 +12,7 @@ def retry_(new_method, on: StandardError, times: 3, &condition) # rubocop:disabl
rescue on
next
end
return retval unless condition.call(retval)
return retval unless block_given? && yield(retval)
end
return method(orig_method).call(*args, &block)
end
Expand Down

0 comments on commit 97dfce2

Please sign in to comment.