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