Method: Sfn::CommandModule::Callbacks#api_action!

Defined in:
lib/sfn/command_module/callbacks.rb

#api_action!(*args) ⇒ Object

Run expected callbacks around action

Returns:

  • (Object)

    result of yield block



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sfn/command_module/callbacks.rb', line 15

def api_action!(*args)
  type = self.class.name.split("::").last.downcase
  run_callbacks_for(["before_#{type}", :before], *args)
  result = nil
  begin
    result = yield if block_given?
    run_callbacks_for(["after_#{type}", :after], *args)
    result
  rescue => err
    run_callbacks_for(["failed_#{type}", :failed], *(args + [err]))
    raise
  end
end