module ActionLogic::ActionBenchmark::ClassMethods

Public Instance Methods

with_benchmark(execution_context, &block) click to toggle source
# File lib/action_logic/action_benchmark.rb, line 4
def with_benchmark(execution_context, &block)
  ActionLogic.benchmark? ? benchmark!(execution_context, &block) : block.call
end

Private Instance Methods

benchmark!(execution_context, &block) click to toggle source
# File lib/action_logic/action_benchmark.rb, line 10
def benchmark!(execution_context, &block)
  context = nil
  benchmark_result  = ActionLogic.benchmark_handler.call { context = block.call }
  log!(benchmark_result, execution_context)
  context
end
log!(benchmark_result, execution_context) click to toggle source
# File lib/action_logic/action_benchmark.rb, line 17
def log!(benchmark_result, execution_context)
  ActionLogic.benchmark_formatter.send("log_#{execution_context.__private__type}".to_sym,
                                       benchmark_result,
                                       execution_context.name)
end