Module: Mongoid::Config::Options
- Included in:
- Mongoid::Config
- Defined in:
- lib/mongoid/config/options.rb
Overview
Encapsulates logic for setting options.
Instance Method Summary collapse
-
#defaults ⇒ Hash
Get the defaults or initialize a new empty hash.
-
#option(name, options = {}) ⇒ Object
Define a configuration option with a default.
-
#reset ⇒ Hash
Reset the configuration options to the defaults.
-
#settings ⇒ Hash
Get the settings or initialize a new empty hash.
Instance Method Details
#defaults ⇒ Hash
Get the defaults or initialize a new empty hash.
16 17 18 |
# File 'lib/mongoid/config/options.rb', line 16 def defaults @defaults ||= {} end |
#option(name, options = {}) ⇒ Object
Define a configuration option with a default.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/mongoid/config/options.rb', line 31 def option(name, = {}) defaults[name] = settings[name] = [:default] class_eval <<-RUBY def #{name} settings[#{name.inspect}] end def #{name}=(value) settings[#{name.inspect}] = value end def #{name}? #{name} end RUBY end |
#reset ⇒ Hash
Reset the configuration options to the defaults.
57 58 59 |
# File 'lib/mongoid/config/options.rb', line 57 def reset settings.replace(defaults) end |
#settings ⇒ Hash
Get the settings or initialize a new empty hash.
69 70 71 |
# File 'lib/mongoid/config/options.rb', line 69 def settings @settings ||= {} end |