Skip to content

Commit

Permalink
use undef_method to avoid NameError exceptions all the time
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Apr 1, 2012
1 parent 67b000e commit 0244c0d
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 0244c0d

Please sign in to comment.