lib/parelation/criteria/order/object.rb in parelation-0.1.0 vs lib/parelation/criteria/order/object.rb in parelation-0.2.0
- old
+ new
@@ -1,7 +1,15 @@
class Parelation::Criteria::Order::Object
+ # @return [Hash] the possible directions (asc, desc)
+ # for database queries.
+ #
+ DIRECTIONS = {
+ "asc" => :asc,
+ "desc" => :desc,
+ }
+
# @return [String]
#
attr_reader :order
# @param order [String]
@@ -26,17 +34,13 @@
def field
parts.first || ""
end
# @return [Symbol, nil] the direction to order {#field},
- # eiter :asc or :desc.
+ # either :asc or :desc.
#
def direction
- case parts.last
- when "asc" then :asc
- when "desc" then :desc
- else nil
- end
+ DIRECTIONS[parts.last]
end
# @return [Array<String, nil>] the criteria chunks (separated by +:+).
#
def parts