Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2371 from bradediger/issue-2346

remove_possible_method: test if method exists
  • Loading branch information...
commit e022c95eeea0b99f3919223ea446b261bf3c5f43 2 parents 779d78d + 7f88539
@jonleighton jonleighton authored
View
9 activesupport/lib/active_support/core_ext/module/remove_method.rb
@@ -1,11 +1,16 @@
class Module
def remove_possible_method(method)
- remove_method(method)
+ if method_defined?(method) || private_method_defined?(method)
+ remove_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)
remove_possible_method(method)
define_method(method, &block)
end
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.