From 74c9862fc9f24d030a22e75ad3eb5818969fef9e Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Fri, 8 Jan 2010 16:29:06 -0500 Subject: [PATCH] minor: clean up conversions module --- lib/mongo/util/conversions.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mongo/util/conversions.rb b/lib/mongo/util/conversions.rb index a50fc43..a62458f 100644 --- a/lib/mongo/util/conversions.rb +++ b/lib/mongo/util/conversions.rb @@ -19,8 +19,8 @@ module Mongo #:nodoc: # objects to mongo-friendly parameters. module Conversions - ASCENDING = ["ascending", "asc", "1"] - DESCENDING = ["descending", "desc", "-1"] + ASCENDING_CONVERSION = ["ascending", "asc", "1"] + DESCENDING_CONVERSION = ["descending", "desc", "-1"] # Converts the supplied +Array+ to a +Hash+ to pass to mongo as # sorting parameters. The returned +Hash+ will vary depending @@ -76,11 +76,12 @@ module Mongo #:nodoc: # If the value is invalid then an error will be raised. def sort_value(value) val = value.to_s.downcase - return 1 if ASCENDING.include?(val) - return -1 if DESCENDING.include?(val) + return 1 if ASCENDING_CONVERSION.include?(val) + return -1 if DESCENDING_CONVERSION.include?(val) raise InvalidSortValueError.new( "#{self} was supplied as a sort direction when acceptable values are: " + - "Mongo::ASCENDING, 'ascending', 'asc', :ascending, :asc, 1, Mongo::DESCENDING, 'descending', 'desc', :descending, :desc, -1.") + "Mongo::ASCENDING, 'ascending', 'asc', :ascending, :asc, 1, Mongo::DESCENDING, " + + "'descending', 'desc', :descending, :desc, -1.") end end end