Sha256: acaf9d4ac94598303a14c4407b597839d60fc4694b4d6cc556a73116df20ec3a

Contents?: true

Size: 1.26 KB

Versions: 4

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

require "mongo/config/options"
require "mongo/config/validators/option"

module Mongo

  # This module defines configuration options for Mongo.
  #
  # @api private
  module Config
    extend Forwardable
    extend Options
    extend self

    # When this flag is off, an aggregation done on a view will be executed over
    # the documents included in that view, instead of all documents in the
    # collection. When this flag is on, the view filter is ignored.
    option :broken_view_aggregate, default: true

    # When this flag is set to false, the view options will be correctly
    # propagated to readable methods.
    option :broken_view_options, default: true

    # When this flag is set to true, the update and replace methods will
    # validate the parameters and raise an error if they are invalid.
    option :validate_update_replace, default: false

    # Set the configuration options.
    #
    # @example Set the options.
    #   config.options = { validate_update_replace: true }
    #
    # @param [ Hash ] options The configuration options.
    def options=(options)
      options.each_pair do |option, value|
        Validators::Option.validate(option)
        send("#{option}=", value)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
mongo-2.21.0 lib/mongo/config.rb
mongo-2.20.1 lib/mongo/config.rb
mogno-2.20.0 lib/mongo/config.rb
mogno-1.0.0 lib/mongo/config.rb