Class: Quebert::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/quebert/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#backendObject

Returns the value of attribute backend.



5
6
7
# File 'lib/quebert/configuration.rb', line 5

def backend
  @backend
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/quebert/configuration.rb', line 5

def logger
  @logger
end

#workerObject

Returns the value of attribute worker.



5
6
7
# File 'lib/quebert/configuration.rb', line 5

def worker
  @worker
end

Class Method Details

.from_hash(hash) ⇒ Object



37
38
39
# File 'lib/quebert/configuration.rb', line 37

def self.from_hash(hash)
  new.from_hash(hash) # Config this puppy up from a config hash
end

Instance Method Details

#from_hash(hash) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/quebert/configuration.rb', line 23

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

#log_file_path=(path) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/quebert/configuration.rb', line 15

def log_file_path=(path)
  self.logger = begin
    l = Logger.new(path)
    l.formatter = Logger::Formatter.new
    l
  end
end