Sha256: 7ae03d79e93f28434279954b5ffe57ba224098e17830383f41c193f49cd71f9d

Contents?: true

Size: 1.35 KB

Versions: 11

Compression:

Stored size: 1.35 KB

Contents

module Padrino
  module Mailer

    ##
    # Handles MIME type declarations for mail delivery.
    #
    module Mime

      ##
      # Returns Symbol with mime type if found, otherwise use +fallback+.
      # +mime+ should be the content type like "text/plain"
      # +fallback+ may be any symbol
      #
      # Also see the documentation for {MIME_TYPES}.
      #
      # @param [String] mime
      #   The mime alias to fetch (i.e 'text/plain').
      # @param [Symbol] fallback
      #   The fallback mime to use if +mime+ doesn't exist.
      #
      # @example
      #   Padrino::Mailer::Mime.mime_type('text/plain')
      #   # => :plain
      #   Padrino::Mailer::Mime.mime_type('text/html')
      #   # => :html
      #
      # This is a shortcut for:
      #
      #   Padrino::Mailer::Mime::MIME_TYPES.fetch('text/plain', :plain)
      #
      def self.mime_type(mime, fallback=:plain)
        MIME_TYPES.fetch(mime.to_s.downcase, fallback)
      end

      # List of common mime-types, selected from various sources
      # according to their usefulness for an email scope.
      #
      # You can add your own mime types like:
      #
      #   Padrino::Mailer::MIME_TYPES.merge!("text/xml" => :xml)
      #
      MIME_TYPES = {
        "text/html"  => :html,
        "text/plain" => :plain,
        "text/xml"   => :xml
      }
    end # Mime
  end # Mailer
end # Padrino

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
padrino-mailer-0.11.1 lib/padrino-mailer/mime.rb
padrino-mailer-0.11.0 lib/padrino-mailer/mime.rb
padrino-mailer-0.10.7 lib/padrino-mailer/mime.rb
padrino-mailer-0.10.6 lib/padrino-mailer/mime.rb
padrino-mailer-0.10.6.e lib/padrino-mailer/mime.rb
padrino-mailer-0.10.6.d lib/padrino-mailer/mime.rb
padrino-mailer-0.10.6.c lib/padrino-mailer/mime.rb
padrino-mailer-0.10.6.b lib/padrino-mailer/mime.rb
padrino-mailer-0.10.6.a lib/padrino-mailer/mime.rb
padrino-mailer-0.10.5 lib/padrino-mailer/mime.rb
padrino-mailer-0.10.4 lib/padrino-mailer/mime.rb