How to mark deprecated methods in Ruby

Tagged ruby, deprecated  Languages ruby

This code can be used to mark deprecated methods in Ruby:

module Kernel
  def mark_deprecated(new_method)
    warn "DEPRECATED: the #{__method__} called from #{caller.first} has been deprecated and replaced by #{new_method}!!!"
  end
end

Example:

class Horse
  def self.shit
    mark_deprecated("Bull.shit")
  end
end