Sha256: 83fc724068b0a890786b80f1662c888430c23613ce6c75f4e08a87102e4f1f47

Contents?: true

Size: 843 Bytes

Versions: 4

Compression:

Stored size: 843 Bytes

Contents

require 'logger'

module Quebert
  class Configuration
    attr_accessor :backend, :logger, :worker
    
    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 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

4 entries across 4 versions & 1 rubygems

Version Path
quebert-0.0.8 lib/quebert/configuration.rb
quebert-0.0.6 lib/quebert/configuration.rb
quebert-0.0.4 lib/quebert/configuration.rb
quebert-0.0.3 lib/quebert/configuration.rb