diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2015-05-05 05:22:30 +0100 |
---|---|---|
committer | Andrew White <andrew.white@unboxedconsulting.com> | 2015-10-21 16:00:35 +0100 |
commit | 94ca3e0a571dba0fe41ca18d61634c5f3aa11209 (patch) | |
tree | c794b8303a486432e8ddf057c82259f0e904369f /activesupport/lib/active_support/core_ext/module/remove_method.rb | |
parent | 173fc1f7beed616adc840e02fef4e7f93e877c69 (diff) | |
download | rails-94ca3e0a571dba0fe41ca18d61634c5f3aa11209.tar.gz rails-94ca3e0a571dba0fe41ca18d61634c5f3aa11209.tar.bz2 rails-94ca3e0a571dba0fe41ca18d61634c5f3aa11209.zip |
Add Module#remove_possible_singleton_method
This is primarily to fix method redefinition warnings in class_attribute
but may be of use in other places where we define singleton methods.
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module/remove_method.rb')
-rw-r--r-- | activesupport/lib/active_support/core_ext/module/remove_method.rb | 7 |
1 files changed, 7 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 52632d2c6b..287ec477a0 100644 --- a/activesupport/lib/active_support/core_ext/module/remove_method.rb +++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb @@ -6,6 +6,13 @@ class Module end end + # Removes the named singleton method, if it exists. + def remove_possible_singleton_method(method) + singleton_class.instance_eval do + remove_possible_method(method) + end + end + # Replaces the existing method definition, if there is one, with the passed # block as its body. def redefine_method(method, &block) |