aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/grouping.rb
blob: 39b5942bcce3e4896757be1a500cda7726410afa (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 Arel
  class Grouping < Compound
    attr_reader :groupings

    def initialize(relation, *groupings)
      @relation, @groupings = relation, groupings.collect { |g| g.bind(relation) }
    end

    def ==(other)
      Grouping    == other.class      and
      relation    == other.relation   and
      groupings   == other.groupings
    end

    def aggregation?
      true
    end
    
    def name
      relation.name + '_aggregation'
    end
  end
end