blob: 38f1f2dda8da9ff7837e5879f5a056f2f89bf407 (
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
24
25
26
27
28
|
module ActiveRelation
class Aggregation < Compound
attr_reader :expressions, :groupings
def initialize(relation, options)
@relation, @expressions, @groupings = relation, options[:expressions], options[:groupings]
end
def ==(other)
self.class == other.class and
relation == other.relation and
groupings == other.groupings and
expressions == other.expressions
end
def attributes
expressions.collect { |e| e.bind(self) }
end
def aggregation?
true
end
def descend(&block)
Aggregation.new(relation.descend(&block), :expressions => expressions.collect(&block), :groupings => groupings.collect(&block))
end
end
end
|