123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Associations::JoinDependency::Aliases

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Classes:
Inherits: Object
Defined in: activerecord/lib/active_record/associations/join_dependency.rb

Class Method Summary

Instance Method Summary

Constructor Details

.new(tables) ⇒ Aliases

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/join_dependency.rb', line 14

def initialize(tables)
  @tables = tables
  @alias_cache = tables.each_with_object({}) { |table, h|
    h[table.node] = table.columns.each_with_object({}) { |column, i|
      i[column.name] = column.alias
    }
  }
  @columns_cache = tables.each_with_object({}) { |table, h|
    h[table.node] = table.columns
  }
end

Instance Method Details

#column_alias(node, column)

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/join_dependency.rb', line 34

def column_alias(node, column)
  @alias_cache[node][column]
end

#column_aliases(node)

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/join_dependency.rb', line 30

def column_aliases(node)
  @columns_cache[node]
end

#columns

[ GitHub ]

  
# File 'activerecord/lib/active_record/associations/join_dependency.rb', line 26

def columns
  @tables.flat_map(&:column_aliases)
end