1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

use undef_method to avoid NameError exceptions all the time

This commit is contained in:
Aaron Patterson 2012-03-31 17:21:49 -07:00
parent 67b000ebd5
commit 0244c0d8f3

View file

@ -1,12 +1,8 @@
class Module
def remove_possible_method(method)
if method_defined?(method) || private_method_defined?(method)
remove_method(method)
undef_method(method)
end
rescue NameError
# If the requested method is defined on a superclass or included module,
# method_defined? returns true but remove_method throws a NameError.
# Ignore this.
end
def redefine_method(method, &block)