aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/relations/order.rb
blob: ebb4dc0668414f269e24e9b6a02c7972e3e7854c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
module Arel
  class Order < Compound
    attr_reader :orderings
    
    def initialize(relation, *orderings)
      @relation, @orderings = relation, orderings.collect { |o| o.bind(relation) }
    end

    def orders
      orderings + relation.orders
    end
    
    def ==(other)
      Order       === other          and
      relation    ==  other.relation and
      orderings   ==  other.orderings
    end
  end
end