Module | Mongo::Support |
In: |
lib/mongo/util/support.rb
|
Generate an MD5 for authentication.
@param [String] username @param [String] password @param [String] nonce
@return [String] a key for db authentication.
# File lib/mongo/util/support.rb, line 33 def auth_key(username, password, nonce) Digest::MD5.hexdigest("#{nonce}#{username}#{hash_password(username, password)}") end
# File lib/mongo/util/support.rb, line 70 def format_order_clause(order) case order when String, Symbol then string_as_sort_parameters(order) when Array then array_as_sort_parameters(order) else raise InvalidSortValueError, "Illegal sort clause, '#{order.class.name}'; must be of the form " + "[['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]" end end
# File lib/mongo/util/support.rb, line 47 def validate_db_name(db_name) unless [String, Symbol].include?(db_name.class) raise TypeError, "db_name must be a string or symbol" end [" ", ".", "$", "/", "\\"].each do |invalid_char| if db_name.include? invalid_char raise Mongo::InvalidNSName, "database names cannot contain the character '#{invalid_char}'" end end raise Mongo::InvalidNSName, "database name cannot be the empty string" if db_name.empty? db_name end