aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/module
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-25 18:51:17 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-25 22:30:42 +0100
commit8ba491acc31bf08cf63a83ea0a3c314c52cd020f (patch)
tree617a8a8133b700811cca12942f802bb4c0167904 /activesupport/lib/active_support/core_ext/module
parentbad6803570f5f3b09d277b15c9f272bfae7408da (diff)
downloadrails-8ba491acc31bf08cf63a83ea0a3c314c52cd020f.tar.gz
rails-8ba491acc31bf08cf63a83ea0a3c314c52cd020f.tar.bz2
rails-8ba491acc31bf08cf63a83ea0a3c314c52cd020f.zip
Revert all the stuff to do with disallowing non-public methods for Module#delegate
Diffstat (limited to 'activesupport/lib/active_support/core_ext/module')
-rw-r--r--activesupport/lib/active_support/core_ext/module/delegation.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb
index 8350753f78..7de824a77f 100644
--- a/activesupport/lib/active_support/core_ext/module/delegation.rb
+++ b/activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -1,6 +1,3 @@
-require 'active_support/core_ext/object/public_send'
-require 'active_support/core_ext/string/starts_ends_with'
-
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)
@@ -127,13 +124,12 @@ class Module
methods.each do |method|
method = method.to_s
- call = method.ends_with?('=') ? "public_send(:#{method}, " : "#{method}("
if allow_nil
module_eval(<<-EOS, file, line - 2)
def #{method_prefix}#{method}(*args, &block) # def customer_name(*args, &block)
if #{to} || #{to}.respond_to?(:#{method}) # if client || client.respond_to?(:name)
- #{to}.#{call}*args, &block) # client.name(*args, &block)
+ #{to}.__send__(:#{method}, *args, &block) # client.__send__(:name, *args, &block)
end # end
end # end
EOS
@@ -142,7 +138,7 @@ class Module
module_eval(<<-EOS, file, line - 1)
def #{method_prefix}#{method}(*args, &block) # def customer_name(*args, &block)
- #{to}.#{call}*args, &block) # client.name(*args, &block)
+ #{to}.__send__(:#{method}, *args, &block) # client.__send__(:name, *args, &block)
rescue NoMethodError # rescue NoMethodError
if #{to}.nil? # if client.nil?
#{exception} # # add helpful message to the exception