Class: Mail::Configuration

Inherits:
Object show all
Includes:
Singleton
Defined in:
lib/mail/configuration.rb

Overview

The Configuration class is a Singleton used to hold the default configuration for all Mail objects.

Each new mail object gets a copy of these values at initialization which can be overwritten on a per mail object basis.

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



17
18
19
20
21
# File 'lib/mail/configuration.rb', line 17

def initialize
  @delivery_method  = nil
  @retriever_method = nil
  super
end

Instance Method Details

#delivery_method(method = nil, settings = {}) ⇒ Object



23
24
25
26
# File 'lib/mail/configuration.rb', line 23

def delivery_method(method = nil, settings = {})
  return @delivery_method if @delivery_method && method.nil?
  @delivery_method = lookup_delivery_method(method).new(settings)
end

#lookup_delivery_method(method) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/mail/configuration.rb', line 28

def lookup_delivery_method(method)
  case method
  when nil
    Mail::SMTP
  when :smtp
    Mail::SMTP
  when :sendmail
    Mail::Sendmail
  when :exim
    Mail::Exim
  when :file
    Mail::FileDelivery
  when :smtp_connection
    Mail::SMTPConnection
  when :test
    Mail::TestMailer
  else
    method
  end
end

#lookup_retriever_method(method) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/mail/configuration.rb', line 54

def lookup_retriever_method(method)
  case method
  when nil
    Mail::POP3
  when :pop3
    Mail::POP3
  when :imap
    Mail::IMAP
  when :test
    Mail::TestRetriever
  else
    method
  end
end

#param_encode_language(value = nil) ⇒ Object



69
70
71
# File 'lib/mail/configuration.rb', line 69

def param_encode_language(value = nil)
  value ? @encode_language = value : @encode_language ||= 'en'
end

#retriever_method(method = nil, settings = {}) ⇒ Object



49
50
51
52
# File 'lib/mail/configuration.rb', line 49

def retriever_method(method = nil, settings = {})
  return @retriever_method if @retriever_method && method.nil?
  @retriever_method = lookup_retriever_method(method).new(settings)
end