class Quebert::Configuration

Attributes

backend[RW]
logger[RW]
worker[RW]

Public Class Methods

from_hash(hash) click to toggle source
# 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

Public Instance Methods

after_job(job = nil, &block) click to toggle source
# File lib/quebert/configuration.rb, line 52
def after_job(job = nil, &block)
  if job
    after_hooks.each do |h|
      h.call(job)
    end
  else
    after_hooks << block if block
  end
  self
end
around_job(job = nil, &block) click to toggle source
# File lib/quebert/configuration.rb, line 63
def around_job(job = nil, &block)
  if job
    around_hooks.each do |h|
      h.call(job)
    end
  else
    around_hooks << block if block
  end
  self
end
before_job(job = nil, &block) click to toggle source
# File lib/quebert/configuration.rb, line 41
def before_job(job = nil, &block)
  if job
    before_hooks.each do |h|
      h.call(job)
    end
  else
    before_hooks << block if block
  end
  self
end
from_hash(hash) click to toggle source
# 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) click to toggle source
# 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

Private Instance Methods

after_hooks() click to toggle source
# File lib/quebert/configuration.rb, line 80
def after_hooks
  @after_hooks ||= []
end
around_hooks() click to toggle source
# File lib/quebert/configuration.rb, line 84
def around_hooks
  @around_hooks ||= []
end
before_hooks() click to toggle source
# File lib/quebert/configuration.rb, line 76
def before_hooks
  @before_hooks ||= []
end