Class: Mail::Configuration

Inherits:
Object
  • 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.



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

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

Instance Method Details

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



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

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



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

def lookup_delivery_method(method)
  case method.is_a?(String) ? method.to_sym : 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
  when :logger
    Mail::LoggerDelivery
  else
    method
  end
end

#lookup_retriever_method(method) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/mail/configuration.rb', line 57

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



72
73
74
# File 'lib/mail/configuration.rb', line 72

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

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



52
53
54
55
# File 'lib/mail/configuration.rb', line 52

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