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