aboutsummaryrefslogblamecommitdiffstats
path: root/lib/arel/relations/operations/project.rb
blob: 0efc13bdb38e4e9eb103275a0a63310bfd6a477a (plain) (tree)
1
2
3
4
5
6
7
8
9
           
                          



                                                     

       
                  
                                                              

       


                                     
    
                 
                                     

                                        
       

     
module Arel
  class Project < Compound
    attr_reader :projections
    
    def initialize(relation, *projections)
      @relation, @projections = relation, projections
    end

    def attributes
      @attributes ||= projections.collect { |p| p.bind(self) }
    end
    
    def aggregation?
      attributes.any?(&:aggregation?)
    end
    
    def ==(other)
      Project  === other          and
      relation    ==  other.relation and
      projections ==  other.projections
    end
  end
end