Class: Retry::Engine
- Inherits:
-
Object
- Object
- Retry::Engine
- Defined in:
- lib/retry.rb
Overview
Support for repeatedly calling retriable operations
Instance Attribute Summary collapse
-
#delay ⇒ Object
Returns the value of attribute delay.
-
#exceptions ⇒ Object
Returns the value of attribute exceptions.
-
#handlers ⇒ Object
Returns the value of attribute handlers.
-
#tries ⇒ Object
Returns the value of attribute tries.
Instance Method Summary collapse
-
#do(delay: nil, exceptions: nil, handlers: nil, tries: nil, &block) ⇒ Object
Executes the class method do using instance default values.
-
#initialize(delay: nil, exceptions: nil, handlers: nil, tries: nil) ⇒ void
constructor
Initialises a new Engine instance.
Constructor Details
#initialize(delay: nil, exceptions: nil, handlers: nil, tries: nil) ⇒ void
Initialises a new Engine instance
45 46 47 48 49 50 |
# File 'lib/retry.rb', line 45 def initialize(delay: nil, exceptions: nil, handlers: nil, tries: nil) self.delay = delay.to_f self.exceptions = exceptions || {} self.handlers = handlers || {} self.tries = tries end |
Instance Attribute Details
#delay ⇒ Object
Returns the value of attribute delay.
30 31 32 |
# File 'lib/retry.rb', line 30 def delay @delay end |
#exceptions ⇒ Object
Returns the value of attribute exceptions.
31 32 33 |
# File 'lib/retry.rb', line 31 def exceptions @exceptions end |
#handlers ⇒ Object
Returns the value of attribute handlers.
32 33 34 |
# File 'lib/retry.rb', line 32 def handlers @handlers end |
#tries ⇒ Object
Returns the value of attribute tries.
33 34 35 |
# File 'lib/retry.rb', line 33 def tries @tries end |
Instance Method Details
#do(delay: nil, exceptions: nil, handlers: nil, tries: nil, &block) ⇒ Object
Executes the class method do using instance default values
53 54 55 56 57 58 59 |
# File 'lib/retry.rb', line 53 def do(delay: nil, exceptions: nil, handlers: nil, tries: nil, &block) Retry.do(delay: delay || self.delay, exceptions: exceptions || self.exceptions, handlers: handlers || self.handlers, tries: tries || self.tries, &block) end |