blob: 9e803b3587397c36432cb80989d55db9f97264cc (
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
29
|
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 qualify
Aggregation.new(relation.qualify, :expressions => expressions.collect(&:qualify), :groupings => groupings.collect(&:qualify))
end
def attributes
expressions.collect { |e| e.bind(self) }
end
protected
def aggregation?
true
end
end
end
|