From d7795a9fa73b30099b7f4d0a8551b67dee8c14d0 Mon Sep 17 00:00:00 2001 From: kauzlaricmarko Date: Mon, 8 Apr 2024 14:17:41 +0200 Subject: [PATCH] use yield instead of block.call --- lib/common/retryer.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/common/retryer.rb b/lib/common/retryer.rb index 68dba85..5839e58 100644 --- a/lib/common/retryer.rb +++ b/lib/common/retryer.rb @@ -1,13 +1,13 @@ class Retryer extend ClassFunctional - def self.call(options = {}, &block) + def self.call(options = {}) no_of_repeats, sleep_duration = no_of_repeats_and_sleep_duration(options) count = 0 rv = {} while count < no_of_repeats - rv = retry_once(&block) + rv = retry_once { yield } return rv[:rv] if rv[:status] == 'OK' count = count + 1 warn "#{rv[:exception].class}: #{rv[:exception].message}, retry #{count} of #{no_of_repeats}" @@ -21,9 +21,9 @@ def self.no_of_repeats_and_sleep_duration(options) return options[:repeats] || 2, options[:sleeps] || 0.seconds end - def self.retry_once(&block) + def self.retry_once { - rv: block.call, + rv: yield, status: 'OK' } rescue Exception => e