aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-01-05 17:14:14 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-01-05 17:14:14 -0700
commitc24e9c9be4c388dbc4fbebb06092a91ff79eafab (patch)
tree5dbb06ef2a6784daedac06f1741c2b977bef861b /activesupport/lib
parent1ab7eba89b93135940bd4ec4d799e62cecbfd2ba (diff)
parentaf211a1e079bd937bdde9413df7042a5267feb38 (diff)
downloadrails-c24e9c9be4c388dbc4fbebb06092a91ff79eafab.tar.gz
rails-c24e9c9be4c388dbc4fbebb06092a91ff79eafab.tar.bz2
rails-c24e9c9be4c388dbc4fbebb06092a91ff79eafab.zip
Merge pull request #18355 from georgemillo/docs
Documenting 'remove_possible_method' and 'redefine_method' [ci skip]
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/module/remove_method.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/remove_method.rb b/activesupport/lib/active_support/core_ext/module/remove_method.rb
index 719071d1c2..8a2569a7d0 100644
--- a/activesupport/lib/active_support/core_ext/module/remove_method.rb
+++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb
@@ -1,10 +1,13 @@
class Module
+ # Remove the named method, if it exists.
def remove_possible_method(method)
if method_defined?(method) || private_method_defined?(method)
undef_method(method)
end
end
+ # Replace the existing method definition, if there is one, with the contents
+ # of the block.
def redefine_method(method, &block)
remove_possible_method(method)
define_method(method, &block)