aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/relations/projection.rb
blob: 9e0725f6c58489f011bd1de2f3f64072158b0588 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module ActiveRelation
  class Projection < Compound
    attr_reader :projections
    alias_method :attributes, :projections
    
    def initialize(relation, *projections)
      @relation, @projections = relation, projections
    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