Sha256: fb0d50746ab2d9d2de94b0f5a7f1b1da6499f878dd91d421ebb32c45d76d27b5

Contents?: true

Size: 724 Bytes

Versions: 2

Compression:

Stored size: 724 Bytes

Contents

require 'logger'
require 'tmpdir'

module Billy
  class Config
    DEFAULT_WHITELIST = ['127.0.0.1', 'localhost']

    attr_accessor :logger, :cache, :whitelist, :ignore_params, :persist_cache, :cache_path

    def initialize
      @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
      reset
    end

    def reset
      @cache = true
      @whitelist = DEFAULT_WHITELIST
      @ignore_params = []
      @persist_cache = false
      @cache_path = Dir.tmpdir
    end
  end

  def self.configure
    yield config if block_given?
    config
  end

  def self.log(*args)
    unless config.logger.nil?
      config.logger.send(*args)
    end
  end

  private

  def self.config
    @config ||= Config.new
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
puffing-billy-0.2.1 lib/billy/config.rb
puffing-billy-0.2.0 lib/billy/config.rb