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