module Faraday::Deprecate

def deprecate(name, repl, ver, custom_message = nil)

Parameters:
  • ver (String) -- the semver the method will be removed.
  • repl (#to_s, :none) -- the replacement to use, when `:none` it will
  • name (Symbol) -- the method symbol to deprecate
def deprecate(name, repl, ver, custom_message = nil)
  class_eval do
    gem_ver = Gem::Version.new(ver)
    old = "_deprecated_#{name}"
    alias_method old, name
    define_method name do |*args, &block|
      mod = is_a? Module
      target = mod ? "#{self}." : "#{self.class}#"
      target_message = if name == :inherited
                         "Inheriting #{self}"
                       else
                         "#{target}#{name}"
                       end
      msg = [
        "NOTE: #{target_message} is deprecated",
        repl == :none ? ' with no replacement' : "; use #{repl} instead. ",
        "It will be removed in or after version #{gem_ver} ",
        custom_message,
        "\n#{target}#{name} called from #{Gem.location_of_caller.join(':')}"
      ]
      warn "#{msg.join}." unless Faraday::Deprecate.skip
      send old, *args, &block
    end
  end
end