Module: LightServiceExt::AroundActionExecuteExtension

Defined in:
lib/light-service-ext/around_action_execute_extension.rb

Instance Method Summary collapse

Instance Method Details

#execute(context) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/light-service-ext/around_action_execute_extension.rb', line 5

def execute(context)
  return context if context.status == Status::COMPLETE
  self.before_execute_block.call(context)

  result = super(context.merge(invoked_action: self))

  context.merge!(result)
  context.fail! if result.errors.present?

  self.after_execute_block.call(context)
  self.after_success_block.call(context) if result.success?
  self.after_failure_block.call(context) if result.failure?
  result
end