aboutsummaryrefslogblamecommitdiffstats
path: root/lib/arel/nodes/table_alias.rb
blob: 4f1d70ee54ee52e51d9b8abe513cccea3d61c19f (plain) (tree)



















                                                      
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