mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
20 lines
437 B
Ruby
20 lines
437 B
Ruby
module Arel
|
|
module Nodes
|
|
class TableAlias
|
|
attr_reader :name, :relation, :columns
|
|
|
|
def initialize name, relation
|
|
@name = name
|
|
@relation = relation
|
|
@columns = relation.columns.map { |column|
|
|
column.dup.tap { |col| col.relation = self }
|
|
}
|
|
end
|
|
|
|
def [] name
|
|
name = name.to_s
|
|
columns.find { |column| column.name == name }
|
|
end
|
|
end
|
|
end
|
|
end
|