Method: ActiveRecord::Associations::AliasTracker.create
- Defined in:
- activerecord/lib/active_record/associations/alias_tracker.rb
.create(pool, initial_table, joins, aliases = nil) ⇒ Object
:nodoc:
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'activerecord/lib/active_record/associations/alias_tracker.rb', line 9 def self.create(pool, initial_table, joins, aliases = nil) pool.with_connection do |connection| if joins.empty? aliases ||= Hash.new(0) elsif aliases default_proc = aliases.default_proc || proc { 0 } aliases.default_proc = proc { |h, k| h[k] = initial_count_for(connection, k, joins) + default_proc.call(h, k) } else aliases = Hash.new { |h, k| h[k] = initial_count_for(connection, k, joins) } end aliases[initial_table] = 1 new(connection.table_alias_length, aliases) end end |