Module: Kudan
- Defined in:
- lib/kudan/kudan.rb,
lib/kudan/version.rb,
lib/kudan/configuration.rb
Defined Under Namespace
Classes: Configuration
Constant Summary collapse
- VERSION =
'2.0.0'.freeze
Class Method Summary collapse
- .configuration ⇒ Object
- .disable ⇒ Object
- .enable ⇒ Object
- .enabled? ⇒ Boolean
- .retryable(options = {}) ⇒ Object
Class Method Details
.configuration ⇒ Object
18 19 20 |
# File 'lib/kudan/kudan.rb', line 18 def configuration @configuration ||= Configuration.new end |
.disable ⇒ Object
6 7 8 |
# File 'lib/kudan/kudan.rb', line 6 def disable configuration.enabled = false end |
.enable ⇒ Object
14 15 16 |
# File 'lib/kudan/kudan.rb', line 14 def enable configuration.enabled = true end |
.enabled? ⇒ Boolean
10 11 12 |
# File 'lib/kudan/kudan.rb', line 10 def enabled? configuration.enabled end |
.retryable(options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kudan/kudan.rb', line 22 def retryable( = {}) opts = configuration.config.merge() enabled = opts.fetch(:enabled) sleep_seconds = opts.fetch(:sleep_seconds) tries = opts.fetch(:tries) retries = 0 retry_exception = nil begin yield retries, retry_exception rescue StandardError => exception raise unless enabled raise if retries + 1 > tries sleep(sleep_seconds) retries += 1 retry_exception = exception retry end end |