Class: Retryable::Configuration
- Inherits:
-
Object
- Object
- Retryable::Configuration
- Defined in:
- lib/retryable/configuration.rb
Overview
Used to set up and modify settings for the retryable.
Constant Summary collapse
- OPTIONS =
[ :ensure, :exception_cb, :matching, :on, :sleep, :tries, :not ].freeze
Instance Attribute Summary collapse
-
#enabled ⇒ Object
(also: #enabled?)
Returns the value of attribute enabled.
-
#ensure ⇒ Object
Returns the value of attribute ensure.
-
#exception_cb ⇒ Object
Returns the value of attribute exception_cb.
-
#matching ⇒ Object
Returns the value of attribute matching.
-
#not ⇒ Object
Returns the value of attribute not.
-
#on ⇒ Object
Returns the value of attribute on.
-
#sleep ⇒ Object
Returns the value of attribute sleep.
-
#tries ⇒ Object
Returns the value of attribute tries.
Instance Method Summary collapse
-
#[](option) ⇒ Object
Allows config options to be read like a hash.
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with
hash. -
#to_hash ⇒ Object
Returns a hash of all configurable options.
Constructor Details
#initialize ⇒ Configuration
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/retryable/configuration.rb', line 26 def initialize @ensure = Proc.new {} @exception_cb = Proc.new {} @matching = /.*/ @on = StandardError @sleep = 1 @tries = 2 @not = [] @enabled = true end |
Instance Attribute Details
#enabled ⇒ Object Also known as: enabled?
Returns the value of attribute enabled.
22 23 24 |
# File 'lib/retryable/configuration.rb', line 22 def enabled @enabled end |
#ensure ⇒ Object
Returns the value of attribute ensure.
14 15 16 |
# File 'lib/retryable/configuration.rb', line 14 def ensure @ensure end |
#exception_cb ⇒ Object
Returns the value of attribute exception_cb.
15 16 17 |
# File 'lib/retryable/configuration.rb', line 15 def exception_cb @exception_cb end |
#matching ⇒ Object
Returns the value of attribute matching.
16 17 18 |
# File 'lib/retryable/configuration.rb', line 16 def matching @matching end |
#not ⇒ Object
Returns the value of attribute not.
20 21 22 |
# File 'lib/retryable/configuration.rb', line 20 def not @not end |
#on ⇒ Object
Returns the value of attribute on.
17 18 19 |
# File 'lib/retryable/configuration.rb', line 17 def on @on end |
#sleep ⇒ Object
Returns the value of attribute sleep.
18 19 20 |
# File 'lib/retryable/configuration.rb', line 18 def sleep @sleep end |
#tries ⇒ Object
Returns the value of attribute tries.
19 20 21 |
# File 'lib/retryable/configuration.rb', line 19 def tries @tries end |
Instance Method Details
#[](option) ⇒ Object
Allows config options to be read like a hash
49 50 51 |
# File 'lib/retryable/configuration.rb', line 49 def [](option) send(option) end |
#disable ⇒ Object
42 43 44 |
# File 'lib/retryable/configuration.rb', line 42 def disable @enabled = false end |
#enable ⇒ Object
38 39 40 |
# File 'lib/retryable/configuration.rb', line 38 def enable @enabled = true end |
#merge(hash) ⇒ Object
Returns a hash of all configurable options merged with hash
64 65 66 |
# File 'lib/retryable/configuration.rb', line 64 def merge(hash) to_hash.merge(hash) end |
#to_hash ⇒ Object
Returns a hash of all configurable options
54 55 56 57 58 59 |
# File 'lib/retryable/configuration.rb', line 54 def to_hash OPTIONS.inject({}) do |hash, option| hash[option.to_sym] = self.send(option) hash end end |