Sha256: b3be8b6882d1071279c7277a51abdd6cbf85c267da1dd29cb185624fa2050f26

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

# frozen_string_literal: true

require "mime/types/logger"

# The namespace for MIME applications, tools, and libraries.
module MIME
  ##
  class Types
    # Used to mark a method as deprecated in the mime-types interface.
    def self.deprecated(klass, sym, message = nil, &block) # :nodoc:
      level =
        case klass
              when Class, Module
                "."
              else
                klass = klass.class
                "#"
        end
      message =
        case message
                when :private, :protected
                  "and will be #{message}"
                when nil
                  "and will be removed"
                else
                  message
        end
      MIME::Types.logger.warn <<~WARNING.chomp
        #{caller(2..2).first}: #{klass}#{level}#{sym} is deprecated #{message}.
      WARNING

      return unless block
      block.call
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mime-types-3.4.0 lib/mime/types/deprecations.rb