Skip to content
Browse files

AS guide: documents Module#remove_possible_method

  • Loading branch information...
1 parent dea701b commit 926ff0e0a141e27589b4f5c83e168b10a9ac0a54 @fxn fxn committed Mar 23, 2010
Showing with 19 additions and 0 deletions.
  1. +19 −0 railties/guides/source/active_support_core_extensions.textile
19 railties/guides/source/active_support_core_extensions.textile
@@ -799,6 +799,25 @@ end
NOTE: Defined in +active_support/core_ext/module/delegation.rb+.
+h4. Method Removal
+h5. +remove_possible_method+
+The method +remove_possible_method+ is like the standard +remove_method+, except it silently returns on failure:
+class A; end
+A.class_eval do
+ remove_method(:nonexistent) # raises NameError
+ remove_possible_method(:nonexistent) # no problem, continue
+This may come in handy if you need to define a method that may already exist, since redefining a method issues a warning "method redefined; discarding old redefined_method_name".
+NOTE: Defined in +active_support/core_ext/module/remove_method.rb+.
h4. Parents
h5. +parent+

0 comments on commit 926ff0e

Please sign in to comment.
Something went wrong with that request. Please try again.