aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/operations/order.rb
blob: df54735630b49928680f91dcc10e70fed9e47109 (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
    attributes :relation, :orderings
    deriving   :==
    requires   :ordering

    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