Skip to content
Browse files

we can get a list of reflections from the join parts, so let's remove

the @reflections ivar.
  • Loading branch information...
1 parent e98a877 commit 2a2707f98bab66e2ad08fc7a75fabd6b1ee4153c @tenderlove tenderlove committed
Showing with 5 additions and 3 deletions.
  1. +5 −3 activerecord/lib/active_record/associations/join_dependency.rb
View
8 activerecord/lib/active_record/associations/join_dependency.rb
@@ -4,7 +4,7 @@ class JoinDependency # :nodoc:
autoload :JoinBase, 'active_record/associations/join_dependency/join_base'
autoload :JoinAssociation, 'active_record/associations/join_dependency/join_association'
- attr_reader :join_parts, :reflections, :alias_tracker, :base_klass
+ attr_reader :join_parts, :alias_tracker, :base_klass
def self.make_tree(associations)
hash = {}
@@ -55,7 +55,6 @@ def initialize(base, associations, joins)
@base_klass = base
@table_joins = joins
@join_parts = [JoinBase.new(base)]
- @reflections = []
@alias_tracker = AliasTracker.new(base.connection, joins)
@alias_tracker.aliased_name_for(base.table_name) # Updates the count for base.table_name to 1
tree = self.class.make_tree associations
@@ -74,6 +73,10 @@ def join_associations
join_parts.drop 1
end
+ def reflections
+ join_associations.map(&:reflection)
+ end
+
def join_relation(relation)
join_associations.inject(relation) do |rel,association|
association.join_relation(rel)
@@ -184,7 +187,6 @@ def build(associations, parent, join_type)
def find_or_build_scalar(name, parent, join_type)
reflection = find_reflection parent.base_klass, name
unless join_association = find_join_association(reflection, parent)
- @reflections << reflection
join_association = build_join_association(reflection, parent, join_type)
@join_parts << join_association
end

0 comments on commit 2a2707f

Please sign in to comment.
Something went wrong with that request. Please try again.