diff options
author | eileencodes <eileencodes@gmail.com> | 2014-12-16 14:26:45 -0500 |
---|---|---|
committer | eileencodes <eileencodes@gmail.com> | 2015-01-02 17:15:31 -0500 |
commit | 0408e212ca224bb25159f3e6db2a9c64cdea1200 (patch) | |
tree | bb8f8d8e8ffe8afb9f164398e4556f849f270560 /activerecord/lib/active_record/associations/alias_tracker.rb | |
parent | 16fafd658805407e2bda4f4bb06a70157c21f78a (diff) | |
download | rails-0408e212ca224bb25159f3e6db2a9c64cdea1200.tar.gz rails-0408e212ca224bb25159f3e6db2a9c64cdea1200.tar.bz2 rails-0408e212ca224bb25159f3e6db2a9c64cdea1200.zip |
Initialze `#alias_tracker` with base table name
Instead of initializing an empty connection use the base table name
instead. Split up and refactor `#create` to be 2 methods `#create` and
`#create_with_joins`. Removes the need to update the count by 1 on
initialzing a JoinDependency.
Diffstat (limited to 'activerecord/lib/active_record/associations/alias_tracker.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/alias_tracker.rb | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/associations/alias_tracker.rb b/activerecord/lib/active_record/associations/alias_tracker.rb index 27d918696a..36e62fe6b1 100644 --- a/activerecord/lib/active_record/associations/alias_tracker.rb +++ b/activerecord/lib/active_record/associations/alias_tracker.rb @@ -7,18 +7,21 @@ module ActiveRecord class AliasTracker # :nodoc: attr_reader :aliases - def self.empty(connection) - new connection, Hash.new(0) + def self.create(connection, initial_table) + aliases = Hash.new(0) + aliases[initial_table] = 1 + new connection, aliases end - def self.create(connection, table_joins) - if table_joins.empty? - empty connection + def self.create_with_joins(connection, initial_table, joins, type_caster) + if joins.empty? + create(connection, initial_table, type_caster) else - aliases = Hash.new { |h,k| - h[k] = initial_count_for(connection, k, table_joins) + aliases = Hash.new { |h, k| + h[k] = initial_count_for(connection, k, joins) } - new connection, aliases + aliases[initial_table] = 1 + new connection, aliases, type_caster end end |