Sha256: 89b4cbceaaa3ae1c3e163e700d43f7ad790693a06a9fa39a9e9ec6d3d4f9020c

Contents?: true

Size: 1007 Bytes

Versions: 16

Compression:

Stored size: 1007 Bytes

Contents

require 'logger'

module Quebert
  class Configuration
    attr_accessor :backend, :logger, :worker
    
    def logger
      @logger ||= begin
        l = Logger.new($stdout)
        l.formatter = Logger::Formatter.new
        l
      end
    end
    
    def log_file_path=(path)
      self.logger = begin
        l = Logger.new(path)
        l.formatter = Logger::Formatter.new
        l
      end
    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 worker
      @worker ||= Struct.new(:exception_handler).new
    end
    
    def self.from_hash(hash)
      new.from_hash(hash) # Config this puppy up from a config hash
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
quebert-2.0.3 lib/quebert/configuration.rb
quebert-2.0.2 lib/quebert/configuration.rb
quebert-2.0.1 lib/quebert/configuration.rb
quebert-2.0.0 lib/quebert/configuration.rb
quebert-1.12.0 lib/quebert/configuration.rb
quebert-1.11.0 lib/quebert/configuration.rb
quebert-1.0.9 lib/quebert/configuration.rb
quebert-1.0.8 lib/quebert/configuration.rb
quebert-1.0.7 lib/quebert/configuration.rb
quebert-1.0.6 lib/quebert/configuration.rb
quebert-1.0.5 lib/quebert/configuration.rb
quebert-1.0.4 lib/quebert/configuration.rb
quebert-1.0.2 lib/quebert/configuration.rb
quebert-1.0.1 lib/quebert/configuration.rb
quebert-1.0.0 lib/quebert/configuration.rb
quebert-0.0.9 lib/quebert/configuration.rb