Module: Mongo::Collection::View::Builder::Flags

Extended by:
Flags
Included in:
Flags
Defined in:
lib/mongo/collection/view/builder/flags.rb

Overview

Provides behaviour for mapping flags.

Since:

  • 2.2.0

Constant Summary

MAPPINGS =

Options to cursor flags mapping.

Since:

  • 2.2.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

Instance Method Summary collapse

Instance Method Details

#map_flags(options) ⇒ Array<Symbol>

Maps an array of flags from the provided options.

Examples:

Map the flags.

Flags.map_flags(options)

Parameters:

  • options (Hash, BSON::Document)

    The options.

Returns:

  • (Array<Symbol>)

    The flags.

Since:

  • 2.2.0



49
50
51
52
53
54
55
56
57
# File 'lib/mongo/collection/view/builder/flags.rb', line 49

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