Skip to content

Instantly share code, notes, and snippets.

@pcdavid
Created July 21, 2009 08:48
Show Gist options
  • Save pcdavid/151211 to your computer and use it in GitHub Desktop.
Save pcdavid/151211 to your computer and use it in GitHub Desktop.
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