Method: Mongo::Config::Options#option

Defined in:
lib/mongo/config/options.rb

#option(name, options = {}) ⇒ Object

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.

Define a configuration option with a default.

Parameters:

  • name (Symbol)

    The name of the configuration option.

  • options (Hash) (defaults to: {})

    Extras for the option.

Options Hash (options):

  • :default (Object)

    The default value.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/mongo/config/options.rb', line 23

def option(name, options = {})
  defaults[name] = settings[name] = options[:default]

  class_eval do
    # log_level accessor is defined specially below
    define_method(name) do
      settings[name]
    end

    define_method("#{name}=") do |value|
      settings[name] = value
    end

    define_method("#{name}?") do
      !!send(name)
    end
  end
end