lib/clevic/order_attribute.rb in clevic-0.12.0 vs lib/clevic/order_attribute.rb in clevic-0.13.0.b1
- old
+ new
@@ -1,8 +1,9 @@
=begin rdoc
Store the SQL order_by attributes with ascending and descending values
=end
+# TODO don't use this anymore
class OrderAttribute
attr_reader :direction, :attribute
def initialize( entity_class, sql_order_fragment )
@entity_class = entity_class
@@ -47,7 +48,16 @@
def ==( other )
@entity_class == other.instance_eval( '@entity_class' ) and
self.direction == other.direction and
self.attribute == other.attribute
+ end
+
+ # return -1 for desc, 1 for asc
+ def to_i
+ case direction
+ when :asc; 1
+ when :desc; -1
+ else; raise "unknown direction #{direction}"
+ end
end
end