def to_hash
      config = { database: database, hosts: hosts }
      if username && password
        config.merge!(username: username, password: password)
      end
      config
    end
def to_hash
      config = { database: database, hosts: hosts }
      if username && password
        config.merge!(username: username, password: password)
      end
      config
    end
Get the uri as a Mongoid friendly configuration hash.

 @example Get the uri as a hash.
   uri.to_hash

 @return [ Hash ] The uri as options.

 @since 1.3.0