Module: Mongo::Operation::Find::Builder::Flags Private

Defined in:
lib/mongo/operation/find/builder/flags.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Provides behavior for converting Ruby options to wire protocol flags when sending find and related commands (e.g. explain).

Since:

  • 2.0.0

Constant Summary collapse

MAPPINGS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Options to cursor flags mapping.

Since:

  • 2.0.0

{
  :allow_partial_results => [ :partial ],
  :oplog_replay => [ :oplog_replay ],
  :no_cursor_timeout => [ :no_cursor_timeout ],
  :tailable => [ :tailable_cursor ],
  :tailable_await => [ :await_data, :tailable_cursor],
  :await_data => [ :await_data ],
  :exhaust => [ :exhaust ],
}.freeze

Class Method Summary collapse

Class Method Details

.map_flags(options) ⇒ Array<Symbol>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts Ruby find options to an array of flags.

Any keys in the input hash that are not options that map to flags are ignored.

Parameters:

  • options (Hash, BSON::Document)

    The options.

Returns:

  • (Array<Symbol>)

    The flags.

Since:

  • 2.0.0



48
49
50
51
52
53
54
55
56
# File 'lib/mongo/operation/find/builder/flags.rb', line 48

module_function def map_flags(options)
  MAPPINGS.each.reduce(options[:flags] || []) do |flags, (key, value)|
    cursor_type = options[:cursor_type]
    if options[key] || (cursor_type && cursor_type == key)
      flags.push(*value)
    end
    flags
  end
end