Sha256: b01a18bdd4a0e83cddb4cdf2eed2016a9e5736ff64e8474c8c02f934bb758dac
Contents?: true
Size: 811 Bytes
Versions: 8
Compression:
Stored size: 811 Bytes
Contents
module CurationConcerns module Utils extend ActiveSupport::Concern def retry_unless(number_of_tries, condition, &block) self.class.retry_unless(number_of_tries, condition, &block) end module ClassMethods def retry_unless(number_of_tries, condition, &_block) fail ArgumentError, 'First argument must be an enumerator' unless number_of_tries.is_a? Enumerator fail ArgumentError, 'Second argument must be a lambda' unless condition.respond_to? :call fail ArgumentError, 'Must pass a block of code to retry' unless block_given? number_of_tries.each do result = yield return result unless condition.call end fail 'retry_unless could not complete successfully. Try upping the # of tries?' end end end end
Version data entries
8 entries across 8 versions & 1 rubygems