Sha256: fe4c93c435e94e84fe210c9d89217b88a0ab7657b9ccd3acedfb27504c2ce147

Contents?: true

Size: 1.46 KB

Versions: 79

Compression:

Stored size: 1.46 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
      else
        method
      end
    end

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

  end

end

Version data entries

79 entries across 49 versions & 3 rubygems

Version Path
depengine-0.0.11 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.11 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.10 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.10 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.9 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.9 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.8 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.8 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.7 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.7 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.5 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.5 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.4 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.4 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.3 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.3 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.2 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.2 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.1 etc/isolate/ruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb
depengine-0.0.1 etc/isolate/jruby-1.8/gems/mail-2.2.5/lib/mail/configuration.rb