Created
July 21, 2009 08:48
-
-
Save pcdavid/151211 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Module | |
def deprecate(*methodNames) | |
methodNames.each do |methodName| | |
module_eval <<END | |
alias_method :deprecated_#{methodName}, :#{methodName} | |
def #{methodName}(*args, &block) | |
$stderr.puts "Warning: calling deprecated method #{self}.#{methodName}" | |
return deprecated_#{methodName}(*args, &block) | |
end | |
END | |
end | |
end | |
end | |
class Foo | |
def print; puts "foo"; end | |
end | |
Foo.new.print | |
class Foo | |
deprecate :print | |
end | |
Foo.new.print |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment