Sha256: be6a45636415672e634db5010392aa03de1a2a79a5de3922179286c8201faf3b

Contents?: true

Size: 1006 Bytes

Versions: 8

Compression:

Stored size: 1006 Bytes

Contents

require 'ostruct'

module ActionLogic
  extend self

  def self.configure(&block)
    block.call(configuration_options)
  end

  def self.configuration_options
    @configuration_options ||= OpenStruct.new
  end

  def self.benchmark?
    configuration_options.benchmark || false
  end

  def self.benchmark_log
    configuration_options.benchmark_log || $stdout
  end

  def self.benchmark_formatter
    custom_benchmark_formatter || default_formatter
  end

  def self.benchmark_handler
    configuration_options.benchmark_handler || ActionBenchmark::DefaultBenchmarkHandler.new
  end

  def self.reset!
    @configuration_options = OpenStruct.new
    @custom_benchmark_formatter = nil
    @default_formatter = nil
  end

  def self.custom_benchmark_formatter
    @custom_benchmark_formatter ||= configuration_options.benchmark_formatter &&
      configuration_options.benchmark_formatter.new
  end

  def self.default_formatter
    @default_formatter ||= ActionBenchmark::DefaultFormatter.new
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
action_logic-0.3.3 lib/action_logic/configuration.rb
action_logic-0.3.2 lib/action_logic/configuration.rb
action_logic-0.3.1 lib/action_logic/configuration.rb
action_logic-0.3.0 lib/action_logic/configuration.rb
action_logic-0.2.8 lib/action_logic/configuration.rb
action_logic-0.2.7 lib/action_logic/configuration.rb
action_logic-0.2.6 lib/action_logic/configuration.rb
action_logic-0.2.5 lib/action_logic/configuration.rb