Permalink
Browse files

Merge pull request #2372 from bradediger/issue-2346-3-1-stable

Issue 2346 3-1-stable port
  • Loading branch information...
2 parents 048215a + f2657b0 commit 3c8d805a0f4a063aca07ddfa1d645ea8585505ea @jonleighton jonleighton committed Jul 31, 2011
Showing with 7 additions and 2 deletions.
  1. +7 −2 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

0 comments on commit 3c8d805

Please sign in to comment.