Module: Mongo::Config::Options Private
- 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 Summary collapse
-
#defaults ⇒ Hash
private
Get the defaults or initialize a new empty hash.
-
#option(name, options = {}) ⇒ Object
private
Define a configuration option with a default.
-
#reset ⇒ Hash
private
Reset the configuration options to the defaults.
-
#settings ⇒ Hash
private
Get the settings or initialize a new empty hash.
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, = {}) defaults[name] = settings[name] = [: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 |
#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 |