aboutsummaryrefslogblamecommitdiffstats
path: root/lib/active_relation/relations/projection.rb
blob: d0c68869bddd0f6450ef1a6348d2086aef8daaf6 (plain) (tree)
1
2
3
4
5
6
7
8
                     
                             



                                                     

       



                                              
                 
                                       

                                       


               
                                                                       


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

    def attributes
      projections.collect { |p| p.bind(self) }
    end
    
    def ==(other)
      self.class  == other.class    and
      relation    == other.relation and
      projections == other.projections
    end

    def qualify
      Projection.new(relation.qualify, *projections.collect(&:qualify))
    end
  end
end