Options — Documentation by YARD 0.9.37 (original) (raw)

Module: Mongo::Config::OptionsPrivate

Included in:

Mongo::Config

Defined in:

lib/mongo/config/options.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.

Encapsulates logic for setting options.

Instance Method Summarycollapse

Instance Method Details

#defaults ⇒ Hash

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.

Get the defaults or initialize a new empty hash.

| 13 14 15 | # File 'lib/mongo/config/options.rb', line 13 def defaults @defaults ||= {} end | | -------- | ----------------------------------------------------------------------------------- |

#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.

| 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 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 | | ----------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

#reset ⇒ Hash

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.

Reset the configuration options to the defaults.

48 49 50 # File 'lib/mongo/config/options.rb', line 48 def reset settings.replace(defaults) end

#settings ⇒ Hash

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.

Get the settings or initialize a new empty hash.

| 58 59 60 | # File 'lib/mongo/config/options.rb', line 58 def settings @settings ||= {} end | | -------- | ----------------------------------------------------------------------------------- |