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-09-14 11:20:46 -07:00

21 lines
470 B
Ruby

module Arel
module Nodes
class TableAlias
attr_reader :name, :relation, :columns
alias :table_alias :name
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_sym
columns.find { |column| column.name == name }
end
end
end
end