1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/lib/arel/nodes/table_alias.rb
2010-08-18 16:32:32 -07:00

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