Class: Reacto::Operations::Retry
- Inherits:
-
Object
- Object
- Reacto::Operations::Retry
- Defined in:
- lib/reacto/operations/retry.rb
Instance Method Summary collapse
- #call(tracker) ⇒ Object
-
#initialize(behaviour, retries = 1) ⇒ Retry
constructor
A new instance of Retry.
Constructor Details
#initialize(behaviour, retries = 1) ⇒ Retry
Returns a new instance of Retry.
6 7 8 9 |
# File 'lib/reacto/operations/retry.rb', line 6 def initialize(behaviour, retries = 1) @behaviour = behaviour @retries = retries end |
Instance Method Details
#call(tracker) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/reacto/operations/retry.rb', line 11 def call(tracker) error = ->(e) do @retries = @retries - 1 if @retries < 0 tracker.on_error(e) else @behaviour.call(self.call(tracker)) end end Subscriptions::OperationSubscription.new(tracker, error: error) end |