blob: 26348fb35e9bcbf46e5e4d4360053ba8afaa7eae (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module ActiveRelation
class Aggregation
attr_reader :attribute, :function_sql
def initialize(attribute, function_sql)
@attribute, @function_sql = attribute, function_sql
end
def substitute(new_relation)
Aggregation.new(attribute.substitute(new_relation), function_sql)
end
def to_sql(strategy = nil)
"#{function_sql}(#{attribute.to_sql})"
end
def ==(other)
self.class == other.class and attribute == other.attribute and function_sql == other.function_sql
end
end
end
|