deprecated takes up to three arguments:
A symbol which is the name of the method you wish to deprecate (required)
A string or symbol which is the replacement method. If you provide this, your users will be instructed to use that method instead.
A symbol of :public, :private, or :protected which determines the new scope of the method. If you do not provide one, it will be searched for in the various collections, and scope will be chosen that way.
# File lib/deprecated.rb, line 158 def deprecated(sym, replacement=nil, scope=nil) unless sym.kind_of?(Symbol) raise ArgumentError, "deprecated() requires symbols for its first argument." end meth = instance_method(sym) unless scope pub = public_instance_methods pro = protected_instance_methods pri = private_instance_methods if pub.include?(sym) or pub.include?(sym.to_s) scope = :public elsif pro.include?(sym) or pro.include?(sym.to_s) scope = :protected elsif pri.include?(sym) or pri.include?(sym.to_s) scope = :private end end define_method(sym) do |*args| dep_meth = method(sym).unbind __deprecated_run_action__(sym, replacement) retval = meth.bind(self).call(*args) dep_meth.bind(self) return retval end method(scope).call(sym) if scope return scope end
Deprecated.set_action for class scope. See Deprecated.set_action.
# File lib/deprecated.rb, line 192 def deprecated_set_action(&block) raise "You must provide a block" unless block @__deprecated_run_action__ = block end
Generated with the Darkfish Rdoc Generator 2.