For almost all cases, depending on a library or metaprogramming for a deprecation is overkill. Simply add a comment to the rdoc and call the Kernel#warn
method. For example:
class Foo
# <b>DEPRECATED:</b> Please use <tt>useful</tt> instead.
def useless
warn "[DEPRECATION] `useless` is deprecated. Please use `useful` instead."
useful
end
def useful
# ...
end
end
If you're using Yard instead of rdoc, your doc comment should look like this:
# @deprecated Please use {#useful} instead
Also, don't forget to remove the deprecated method in some future release. Don't make the same mistakes that the Java libraries did.