module Mongo::Collection::View::Builder::Flags

Provides behavior for mapping flags.

@since 2.2.0

Constants

MAPPINGS

Options to cursor flags mapping.

@since 2.2.0

Public Instance Methods

map_flags(options) click to toggle source

Maps an array of flags from the provided options.

@example Map the flags.

Flags.map_flags(options)

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

@return [ Array<Symbol> ] The flags.

@since 2.2.0

# 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