From cd9ffd11e13ef6e62eba2cbd5c3760ff04132820 Mon Sep 17 00:00:00 2001 From: wycats Date: Tue, 16 Mar 2010 23:24:00 -0700 Subject: Eliminate warnings for AM on 1.8 --- activesupport/lib/active_support/core_ext/module/delegation.rb | 6 +++++- activesupport/lib/active_support/core_ext/module/remove_method.rb | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 activesupport/lib/active_support/core_ext/module/remove_method.rb (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 df8aefea5a..d78cecc390 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -34,7 +34,7 @@ class Module # class Foo # CONSTANT_ARRAY = [0,1,2,3] # @@class_array = [4,5,6,7] - # + # # def initialize # @instance_array = [8,9,10,11] # end @@ -120,6 +120,10 @@ class Module end module_eval(<<-EOS, file, line) + if instance_methods(false).map(&:to_s).include?("#{prefix}#{method}") + remove_method("#{prefix}#{method}") + end + def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block) #{to}.__send__(#{method.inspect}, *args, &block) # client.__send__(:name, *args, &block) rescue NoMethodError # rescue NoMethodError diff --git a/activesupport/lib/active_support/core_ext/module/remove_method.rb b/activesupport/lib/active_support/core_ext/module/remove_method.rb new file mode 100644 index 0000000000..2714a46b28 --- /dev/null +++ b/activesupport/lib/active_support/core_ext/module/remove_method.rb @@ -0,0 +1,6 @@ +class Module + def remove_possible_method(method) + remove_method(method) + rescue NameError + end +end \ No newline at end of file -- cgit v1.2.3