Class: Reacto::Operations::RescueAndReplaceError

Inherits:
Object
  • Object
show all
Defined in:
lib/reacto/operations/rescue_and_replace_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(action) ⇒ RescueAndReplaceError

Returns a new instance of RescueAndReplaceError.



6
7
8
# File 'lib/reacto/operations/rescue_and_replace_error.rb', line 6

def initialize(action)
  @action = action
end

Instance Method Details

#call(tracker) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/reacto/operations/rescue_and_replace_error.rb', line 10

def call(tracker)
  error = -> (e) do
    trackable = @action.call(e)

    trackable.send(:do_track, tracker)
  end

  Subscriptions::OperationSubscription.new(tracker, error: error)
end