aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/association_collection.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2010-09-30 20:28:22 -0300
committerJosé Valim <jose.valim@gmail.com>2010-10-02 08:40:38 +0200
commit4e93179ed3f44825c157b54517e5a256f5725a55 (patch)
treef04463b3d31c8a566f52944ec7690df8e85cdc90 /activerecord/lib/active_record/associations/association_collection.rb
parentb95152201871f076a0d5c95e9e6387f68feab94e (diff)
downloadrails-4e93179ed3f44825c157b54517e5a256f5725a55.tar.gz
rails-4e93179ed3f44825c157b54517e5a256f5725a55.tar.bz2
rails-4e93179ed3f44825c157b54517e5a256f5725a55.zip
Refactor AssociationCollection#include? with objects in memory
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/associations/association_collection.rb')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb7
1 files changed, 3 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index a617a0fb36..cb2d9e0a79 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -558,11 +558,10 @@ module ActiveRecord
def include_in_memory?(record)
if @reflection.is_a?(ActiveRecord::Reflection::ThroughReflection)
- @owner.send(proxy_reflection.through_reflection.name.to_sym).map do |source|
- source_reflection_target = source.send(proxy_reflection.source_reflection.name)
- return true if source_reflection_target.respond_to?(:include?) ? source_reflection_target.include?(record) : source_reflection_target == record
+ @owner.send(proxy_reflection.through_reflection.name.to_sym).any? do |source|
+ target = source.send(proxy_reflection.source_reflection.name)
+ target.respond_to?(:include?) ? target.include?(record) : target == record
end
- false
else
@target.include?(record)
end