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:
parent
67b000ebd5
commit
0244c0d8f3
1 changed files with 1 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue