Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

AS guide: documents Module#remove_possible_method

  • Loading branch information...
commit 926ff0e0a141e27589b4f5c83e168b10a9ac0a54 1 parent dea701b
@fxn fxn authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 railties/guides/source/active_support_core_extensions.textile
View
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:
+
+<ruby>
+class A; end
+
+A.class_eval do
+ remove_method(:nonexistent) # raises NameError
+ remove_possible_method(:nonexistent) # no problem, continue
+end
+</ruby>
+
+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+
Please sign in to comment.
Something went wrong with that request. Please try again.