blob: bfd05f48b3e2daf40bd67ecb223ceb2a21a17a8f (
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
|
module ActiveRelation
class Order < Compound
attr_reader :order
def initialize(relation, *orders)
@order = orders.pop
@relation = orders.empty?? relation : Order.new(relation, *orders)
end
def ==(other)
self.class == other.class and
relation == other.relation and
orders == other.orders
end
def descend(&block)
Order.new(relation.descend(&block), *orders.collect(&block))
end
def orders
relation.orders + [order]
end
end
end
|