Permalink
Browse files

Use `public_send` instead of just use `send`.

  • Loading branch information...
1 parent aa85bdb commit 1244aa7c5f871da5e907a39242b63a7aee3308a3 @laurocaetano laurocaetano committed Dec 12, 2013
View
10 activerecord/lib/active_record/relation/delegation.rb
@@ -68,7 +68,7 @@ def #{method}(*args, &block)
RUBY
else
define_method method do |*args, &block|
- scoping { @klass.send(method, *args, &block) }
+ scoping { @klass.public_send(method, *args, &block) }
end
end
end
@@ -87,10 +87,10 @@ def delegate(method, opts = {})
def method_missing(method, *args, &block)
if @klass.respond_to?(method)
self.class.delegate_to_scoped_klass(method)
- scoping { @klass.send(method, *args, &block) }
+ scoping { @klass.public_send(method, *args, &block) }
elsif arel.respond_to?(method)
self.class.delegate method, :to => :arel
- arel.send(method, *args, &block)
+ arel.public_send(method, *args, &block)
else
super
end
@@ -118,9 +118,9 @@ def respond_to?(method, include_private = false)
def method_missing(method, *args, &block)
if @klass.respond_to?(method)
- scoping { @klass.send(method, *args, &block) }
+ scoping { @klass.public_send(method, *args, &block) }
elsif arel.respond_to?(method)
- arel.send(method, *args, &block)
+ arel.public_send(method, *args, &block)
else
super
end
View
8 activerecord/test/cases/relation/delegation_test.rb
@@ -10,15 +10,15 @@ def call_method(target, method)
method_arity = target.to_a.method(method).arity
if method_arity.zero?
- target.send(method)
+ target.public_send(method)
elsif method_arity < 0
if method == :shuffle!
- target.send(method)
+ target.public_send(method)
else
- target.send(method, 1)
+ target.public_send(method, 1)
end
elsif method_arity == 1
- target.send(method, 1)
+ target.public_send(method, 1)
else
raise NotImplementedError
end

0 comments on commit 1244aa7

Please sign in to comment.