Class: Operations::Components::OnFailure

Inherits:
Callback show all
Defined in:
lib/operations/components/on_failure.rb

Overview

‘on_failure` callbacks are called if a command have failed on a stage other than the operation itself or contract. I.e. on policies/preconditions.

Constant Summary

Constants inherited from Base

Base::DEFAULT_NAMES_MAP, Base::MONADS_DO_WRAPPER_SIGNATURES

Instance Method Summary collapse

Instance Method Details

#call(operation_result) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/operations/components/on_failure.rb', line 8

def call(operation_result)
  callback_context = operation_result.context.merge(operation_failure: operation_result.errors.to_h)
  results = callable.map do |entry|
    call_entry(entry, operation_result, **callback_context)
  end

  maybe_report_failure(:on_failure, operation_result.merge(on_failure: results))
end