From 2a2707f98bab66e2ad08fc7a75fabd6b1ee4153c Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 8 Oct 2013 15:22:32 -0700 Subject: we can get a list of reflections from the join parts, so let's remove the @reflections ivar. --- activerecord/lib/active_record/associations/join_dependency.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 1d9db51c34..65131452ae 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -4,7 +4,7 @@ module ActiveRecord 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 @@ module ActiveRecord @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 @@ module ActiveRecord 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 @@ module ActiveRecord 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 -- cgit v1.2.3