Sha256: 36688b2fdd1a9d0d7f305f4a6c5d2ebd681962fd6449336abe9cdcf0b6368440

Contents?: true

Size: 1.48 KB

Versions: 9

Compression:

Stored size: 1.48 KB

Contents

# -*- ruby encoding: utf-8 -*-

# The namespace for MIME applications, tools, and libraries.
module MIME # :nodoc:
end

class << MIME
  # Used to mark a method as deprecated in the mime-types interface.
  def deprecated(klass, sym, message = nil, &block) # :nodoc:
    level = case klass
            when Class, Module
              '.'
            else
              klass = klass.class
              '#'
            end
    unless defined?(@__deprecated) and @__deprecated["#{klass}#{level}#{sym}"]
      message = case message
                when :private, :protected
                  "and will be #{message}"
                when nil
                  "and will be removed"
                else
                  message
                end
      warn "#{klass}#{level}#{sym} is deprecated #{message}."
      (@__deprecated ||= {})["#{klass}#{level}#{sym}"] = true
      block.call if block
    end
  end

  # MIME::InvalidContentType was moved to MIME::Type::InvalidContentType.
  # Provide a single warning about this fact in the interim.
  def const_missing(name) # :nodoc:
    case name.to_s
    when "InvalidContentType"
      warn_about_moved_constants(name)
      MIME::Type.const_get(name.to_sym)
    else
      super
    end
  end

  private
  def warn_about_moved_constants(name) # :nodoc:
    unless defined?(@__warned_constants) and @__warned_constants[name]
      warn "MIME::#{name} is deprecated. Use MIME::Type::#{name} instead."
      (@__warned_constants ||= {})[name] = true
    end
  end
end

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/mime-types-2.5/lib/mime.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/mime-types-2.5/lib/mime.rb
mime-types-2.5 lib/mime.rb
mime-types-2.4.3 lib/mime.rb
mime-types-2.4.2 lib/mime.rb
mime-types-2.4.1 lib/mime.rb
mime-types-2.3 lib/mime.rb
mime-types-2.2 lib/mime.rb
mime-types-2.1 lib/mime.rb