aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/algebra/relations/operations/order.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/algebra/relations/operations/order.rb')
-rw-r--r--lib/arel/algebra/relations/operations/order.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/arel/algebra/relations/operations/order.rb b/lib/arel/algebra/relations/operations/order.rb
new file mode 100644
index 0000000000..a589b56997
--- /dev/null
+++ b/lib/arel/algebra/relations/operations/order.rb
@@ -0,0 +1,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