module Mongo::Operation::Find::Builder::Modifiers

Provides behavior for mapping Ruby options to legacy OP_QUERY find modifiers.

This module is used in two ways:

  1. When Collection#find is invoked with the legacy OP_QUERY syntax (:$query argument etc.), this module is used to map the legacy parameters into the Ruby options that normally are used by applications.

  2. When sending a find operation using the OP_QUERY protocol, this module is used to map the Ruby find options to the modifiers in the wire protocol message.

@api private

Constants

DRIVER_MAPPINGS

Mappings from Ruby options to OP_QUERY modifiers.

SERVER_MAPPINGS

Mappings from OP_QUERY modifiers to Ruby options.

Public Instance Methods

map_driver_options(modifiers) click to toggle source

Transform the provided OP_QUERY modifiers to Ruby options.

@example Transform to driver options.

Modifiers.map_driver_options(modifiers)

@param [ Hash ] modifiers The modifiers.

@return [ BSON::Document ] The Ruby options.

# File lib/mongo/operation/find/builder/modifiers.rb, line 64
                def map_driver_options(modifiers)
  Options::Mapper.transform_documents(modifiers, SERVER_MAPPINGS)
end
map_server_modifiers(options) click to toggle source

Transform the provided Ruby options into a document of OP_QUERY modifiers.

Accepts both string and symbol keys.

The input mapping may contain additional keys that do not map to OP_QUERY modifiers, in which case the extra keys are ignored.

@example Map the server modifiers.

Modifiers.map_server_modifiers(options)

@param [ Hash, BSON::Document ] options The options.

@return [ BSON::Document ] The modifiers.

# File lib/mongo/operation/find/builder/modifiers.rb, line 82
                def map_server_modifiers(options)
  Options::Mapper.transform_documents(options, DRIVER_MAPPINGS)
end