Class: RubyQmail::Config

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

Overview

Configuration for the Qmail system. Loads a configuration YAML file, and accepts a Hash of run-time overrides.

Constant Summary collapse

DEFAULTS =
{
  :qmqp_port => 628,
  :qmail_root => '/var/qmail',
  :delimiter => '-',
  :logger    => Logger.new("#{ENV['HOME']}/logs/ruby-qmail.log")
}
QMQP_SERVERS =
'/control/qmqpservers'
QMAIL_QUEUE =
'/bin/qmail-queue'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



26
27
28
# File 'lib/config.rb', line 26

def method_missing(method)
  @options[method.to_sym]
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/config.rb', line 6

def options
  @options
end

Class Method Details

.load_file(config_file, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/config.rb', line 16

def self.load_file(config_file, options={})
  @options = DEFAULTS.merge(options)
  if config_file && File.exists?(config_file)
    @options = YAML.load_file(config_file).merge(@options)
  end
  @options[:qmail_queue] ||= @options[:qmail_root] + QMAIL_QUEUE
  @options[:qmqp_servers] ||= @options[:qmail_root] + QMQP_SERVERS
  @options
end