aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/operations/order.rb
blob: a589b56997637de70b760ff8d700818807f13e03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Arel
  class Order < Compound
    attributes :relation, :orderings
    deriving :==

    def initialize(relation, *orderings, &block)
      @relation = relation
      @orderings = (orderings + arguments_from_block(relation, &block)) \
        .collect { |o| o.bind(relation) }
    end

    # TESTME
    def orders
      # QUESTION - do we still need relation.orders ?
      (orderings + relation.orders).collect { |o| o.bind(self) }.collect { |o| o.to_ordering }
    end
  end
end