Class: Operations::Components::OnSuccess

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

Overview

on_success callbacks are called when command was successful and implemented to be executed outside the outermost DB transcation (this is configurable but by default AfterCommitEverywhere gem is used). It there is a wrapping transaction (in cases when command is called inside of another command), the inner command result will have empty on_success component (since the callbacks will happen when the wparring command is finished).

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



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/operations/components/on_success.rb', line 14

def call(operation_result)
  callback_result = after_commit.call do
    call_entries(operation_result)
  end

  if callback_result.is_a?(Operations::Result)
    callback_result
  else
    operation_result
  end
end