lib/mongo/uri/options_mapper.rb
def ruby_to_smc(opts)
        rv = {}
        URI_OPTION_MAP.each do |uri_key, spec|
          if spec[:group]
            v = opts[spec[:group]]
            v = v && v[spec[:name]]
          else
            v = opts[spec[:name]]
          end
          unless v.nil?
            if spec[:type]
              v = send("revert_#{spec[:type]}", v)
            end
            canonical_key = URI_OPTION_CANONICAL_NAMES[uri_key]
            unless canonical_key
              raise ArgumentError, "Option #{uri_key} is not known"
            end
            rv[canonical_key] = v
          end
        end
        # For options that default to true, remove the value if it is true.
        %w(retryReads retryWrites).each do |k|
          if rv[k]
            rv.delete(k)
          end
        end
        # Remove auth source when it is $external for mechanisms that default
        # (or require) that auth source.
        if %w(MONGODB-AWS).include?(rv['authMechanism']) && rv['authSource'] == '$external'
          rv.delete('authSource')
        end
        # ssl and tls are aliases, remove ssl ones
        rv.delete('ssl')
        # TODO remove authSource if it is the same as the database,
        # requires this method to know the database specified in the client.
        rv
      end
# Converts Ruby options provided to "standardized MongoClient options".
#
# @param [ Hash ] opts Ruby options to convert.
#
# @return [ Hash ] Standardized MongoClient options.
Converts Ruby options provided to "standardized MongoClient options".
Converts Ruby options provided to " standardized MongoClient options " .
def ruby_to_smc(opts)
        rv = {}
        URI_OPTION_MAP.each do |uri_key, spec|
          if spec[:group]
            v = opts[spec[:group]]
            v = v && v[spec[:name]]
          else
            v = opts[spec[:name]]
          end
          unless v.nil?
            if spec[:type]
              v = send("revert_#{spec[:type]}", v)
            end
            canonical_key = URI_OPTION_CANONICAL_NAMES[uri_key]
            unless canonical_key
              raise ArgumentError, "Option #{uri_key} is not known"
            end
            rv[canonical_key] = v
          end
        end
        %w(retryReads retryWrites).each do |k|
          if rv[k]
            rv.delete(k)
          end
        end
        if %w(MONGODB-AWS).include?(rv['authMechanism']) && rv['authSource'] == '$external'
          rv.delete('authSource')
        end
        rv.delete('ssl')
        rv
      end
def ruby_to_smc ( opts ) rv = { } URI_OPTION_MAP . each do | uri_key , spec | if spec [ :group ] v = opts [ spec [ :group ] ] v = v && v [ spec [ :name ] ] else v = opts [ spec [ :name ] ] end unless v . nil? if spec [ :type ] v = send ( "revert_#{spec[:type]}" , v ) end canonical_key = URI_OPTION_CANONICAL_NAMES [ uri_key ] unless canonical_key raise ArgumentError , "Option #{uri_key} is not known" end rv [ canonical_key ] = v end end %w( retryReads retryWrites ) . each do | k | if rv [ k ] rv . delete ( k ) end end if %w( MONGODB-AWS ) . include? ( rv [ 'authMechanism' ] ) && rv [ 'authSource' ] == '$external' rv . delete ( 'authSource' ) end rv . delete ( 'ssl' ) rv end
Converts Ruby options provided to "standardized MongoClient options".
Converts Ruby options provided to " standardized MongoClient options " .
# For options that default to true, remove the value if it is true. # Remove auth source when it is $external for mechanisms that default # (or require) that auth source. # ssl and tls are aliases, remove ssl ones # TODO remove authSource if it is the same as the database, # requires this method to know the database specified in the client.
Standardized MongoClient options.
Standardized MongoClient options .
 Hash 
opts
opts Ruby options to convert.
opts Ruby options to convert .