From fbe35656a95228f760a2cd09676423ba41fe70ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Fri, 19 Mar 2010 12:01:48 +0100 Subject: Singleton classes returns parent's methods with instance_methods(false) and this makes remove_method in Module#delegate fail. Add a test case and fix the bug. --- activesupport/lib/active_support/core_ext/module/delegation.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/core_ext/module') diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index d78cecc390..db6aea9b87 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/module/remove_method" + class Module # Provides a delegate class method to easily expose contained objects' methods # as your own. Pass one or more methods (specified as symbols or strings) @@ -121,7 +123,7 @@ class Module module_eval(<<-EOS, file, line) if instance_methods(false).map(&:to_s).include?("#{prefix}#{method}") - remove_method("#{prefix}#{method}") + remove_possible_method("#{prefix}#{method}") end def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block) -- cgit v1.2.3