diff options
author | eileencodes <eileencodes@gmail.com> | 2014-12-09 13:56:52 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2015-01-02 17:15:31 -0500 |
commit | cc9b813a821ef90d96405bf618fd691522a11ef9 (patch) | |
tree | 658e05cfecce1d3e78264b6b1c55d41b7ec21fa7 /activerecord/lib | |
parent | f6729309a06f40b32e52f8ee8143d1b1da412597 (diff) | |
download | rails-cc9b813a821ef90d96405bf618fd691522a11ef9.tar.gz rails-cc9b813a821ef90d96405bf618fd691522a11ef9.tar.bz2 rails-cc9b813a821ef90d96405bf618fd691522a11ef9.zip |
Pass `connection` rather than `alias_tracker`
After the refactorings we're only using the connection and not the alias
tracker anymore. This builds on commit 18019.
Reuse the already available `@connection` to reduce the surface area of
the alias tracker's API. We can then remove the `attr_reader` because
the connection is already available.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/alias_tracker.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/association_scope.rb | 8 |
2 files changed, 7 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/alias_tracker.rb b/activerecord/lib/active_record/associations/alias_tracker.rb index f9c9f8afda..27d918696a 100644 --- a/activerecord/lib/active_record/associations/alias_tracker.rb +++ b/activerecord/lib/active_record/associations/alias_tracker.rb @@ -5,7 +5,7 @@ module ActiveRecord # Keeps track of table aliases for ActiveRecord::Associations::ClassMethods::JoinDependency and # ActiveRecord::Associations::ThroughAssociationScope class AliasTracker # :nodoc: - attr_reader :aliases, :connection + attr_reader :aliases def self.empty(connection) new connection, Hash.new(0) @@ -63,7 +63,7 @@ module ActiveRecord Arel::Table.new(table_name, table_options) else # Otherwise, we need to use an alias - aliased_name = connection.table_alias_for(aliased_name) + aliased_name = @connection.table_alias_for(aliased_name) # Update the count aliases[aliased_name] += 1 @@ -80,7 +80,7 @@ module ActiveRecord private def truncate(name) - name.slice(0, connection.table_alias_length - 2) + name.slice(0, @connection.table_alias_length - 2) end end end diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 0fdb3737fd..198a047e18 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -37,7 +37,7 @@ module ActiveRecord chain_head, chain_tail = get_chain(reflection, association, alias_tracker) scope.extending! Array(reflection.options[:extend]) - add_constraints(scope, owner, klass, reflection, alias_tracker, chain_head, chain_tail) + add_constraints(scope, owner, klass, reflection, connection, chain_head, chain_tail) end def join_type @@ -139,10 +139,10 @@ module ActiveRecord [runtime_reflection, prev] end - def add_constraints(scope, owner, assoc_klass, refl, tracker, chain_head, chain_tail) + def add_constraints(scope, owner, assoc_klass, refl, connection, chain_head, chain_tail) owner_reflection = chain_tail table = owner_reflection.alias_name - scope = last_chain_scope(scope, table, owner_reflection, owner, tracker, assoc_klass) + scope = last_chain_scope(scope, table, owner_reflection, owner, connection, assoc_klass) reflection = chain_head loop do @@ -152,7 +152,7 @@ module ActiveRecord unless reflection == chain_tail next_reflection = reflection.next foreign_table = next_reflection.alias_name - scope = next_chain_scope(scope, table, reflection, tracker, assoc_klass, foreign_table, next_reflection) + scope = next_chain_scope(scope, table, reflection, connection, assoc_klass, foreign_table, next_reflection) end # Exclude the scope of the association itself, because that |