module ActionLogic::ActionCore::ClassMethods

Public Instance Methods

around(params, &block) click to toggle source
# File lib/action_logic/action_core.rb, line 19
def around(params, &block)
  with_benchmark(self) do
    execute!(params, &block)
  end
end
execute!(params, &block) click to toggle source
# File lib/action_logic/action_core.rb, line 25
def execute!(params, &block)
  execution_context = self.new(params)

  return execution_context.context if execution_context.break?

  execution_context.set_validation_rules
  execution_context.validations!(:before)
  execution_context.validations!(:around)

  begin
    block.call(execution_context)
  rescue => e
    if execution_context.respond_to?(:error)
      execution_context.error(e)
    else
      raise e
    end
  end

  execution_context.validations!(:after)
  execution_context.validations!(:around)

  execution_context.context
end