Module: Mongo::Config::Options Private
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Extended In:
| |
Defined in: | lib/mongo/config/options.rb |
Overview
Encapsulates logic for setting options.
Instance Method Summary
-
#defaults ⇒ Hash
Internal use only
Get the defaults or initialize a new empty hash.
-
#option(name, options = {})
Internal use only
Define a configuration option with a default.
-
#reset ⇒ Hash
Internal use only
Reset the configuration options to the defaults.
-
#settings ⇒ Hash
Internal use only
Get the settings or initialize a new empty hash.
Instance Method Details
#defaults ⇒ Hash
Get the defaults or initialize a new empty hash.
# File 'lib/mongo/config/options.rb', line 13
def defaults @defaults ||= {} end
#option(name, options = {})
Define a configuration option with a default.
# 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
Reset the configuration options to the defaults.
#settings ⇒ Hash
Get the settings or initialize a new empty hash.
# File 'lib/mongo/config/options.rb', line 58
def settings @settings ||= {} end