Class: Undertaker::Undertaker
- Inherits:
-
Object
- Object
- Undertaker::Undertaker
- Defined in:
- lib/undertaker.rb
Instance Attribute Summary collapse
-
#attempts ⇒ Object
Returns the value of attribute attempts.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#retry_condition ⇒ Object
Returns the value of attribute retry_condition.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(options = {}) ⇒ Undertaker
constructor
A new instance of Undertaker.
- #retry_when(&block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Undertaker
Returns a new instance of Undertaker.
14 15 16 17 18 19 |
# File 'lib/undertaker.rb', line 14 def initialize( = {}) @exceptions = [] @attempts = 0 @limit = [:limit] || 10 @logger = [:logger] || ActiveSupport::Logger.new(STDOUT) end |
Instance Attribute Details
#attempts ⇒ Object
Returns the value of attribute attempts.
11 12 13 |
# File 'lib/undertaker.rb', line 11 def attempts @attempts end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
12 13 14 |
# File 'lib/undertaker.rb', line 12 def limit @limit end |
#retry_condition ⇒ Object
Returns the value of attribute retry_condition.
11 12 13 |
# File 'lib/undertaker.rb', line 11 def retry_condition @retry_condition end |
Instance Method Details
#execute ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/undertaker.rb', line 21 def execute setup_execution yield rescue StandardError => exception add_exception exception if should_retry? setup_retry retry end raise exception end |
#retry_when(&block) ⇒ Object
33 34 35 |
# File 'lib/undertaker.rb', line 33 def retry_when(&block) self.retry_condition = block end |