Sha256: decfff2f3d8e7776d400255e529bd4703b100b54f9f76c07c210233e6584731e

Contents?: true

Size: 753 Bytes

Versions: 1

Compression:

Stored size: 753 Bytes

Contents

require 'logger'

module Quebert
  class Configuration
    attr_accessor :backend, :logger
    
    def logger
      @logger ||= Logger.new($stdout)
    end
    
    def log_file_path=(path)
      self.logger = Logger.new(path)
    end
    
    def from_hash(hash)
      hash = Support.symbolize_keys(hash)
      # Find out backend from the registry and configure
      if backend = Quebert.backends[hash.delete(:backend).to_sym]
        # If the backend supports configuration, do it!
        self.backend = backend.respond_to?(:configure) ? backend.configure(Support.symbolize_keys(hash)) : backend.new
      end
      self
    end
    
    def self.from_hash(hash)
      new.from_hash(hash) # Config this puppy up from a config hash
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
quebert-0.0.1 lib/quebert/configuration.rb