aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_relation/relations/projection.rb
blob: 0f8ea5175c84783bc6a5df30898a44d51754aa78 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 aggregation?
      attributes.any?(&:aggregation?)
    end
  end
end