Sha256: a9dca7a5b4278e1cb1b9d8d5336936ee8b13b2e5b4382606df453504a82e3e80

Contents?: true

Size: 1.54 KB

Versions: 11

Compression:

Stored size: 1.54 KB

Contents

# encoding: utf-8
#
# Thanks to Nicolas Fouché for this wrapper
#
require 'singleton'

module Mail
  
  # 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.
  class Configuration
    include Singleton

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

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

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

    def retriever_method(method = nil, settings = {})
      return @retriever_method if @retriever_method && method.nil?
      @retriever_method = lookup_retriever_method(method).new(settings)
    end
    
    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

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

  end

end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
mail-2.2.15 lib/mail/configuration.rb
mail-2.2.14 lib/mail/configuration.rb
mail-2.2.13 lib/mail/configuration.rb
mail-2.2.12 lib/mail/configuration.rb
mail-2.2.11 lib/mail/configuration.rb
dball-mail-2.2.9.7 lib/mail/configuration.rb
dball-mail-2.2.9.6 lib/mail/configuration.rb
dball-mail-2.2.9.4 lib/mail/configuration.rb
mail-2.2.10 lib/mail/configuration.rb
dball-mail-2.2.9.2 lib/mail/configuration.rb
dball-mail-2.2.9.1 lib/mail/configuration.rb