Module: Dynamoid::Config::Options
- Included in:
- Dynamoid::Config
- Defined in:
- lib/dynamoid/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/dynamoid/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 48 49 50 51 |
# File 'lib/dynamoid/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 def reset_#{name} settings[#{name.inspect}] = defaults[#{name.inspect}] end RUBY end |
#reset ⇒ Hash
Reset the configuration options to the defaults.
61 62 63 |
# File 'lib/dynamoid/config/options.rb', line 61 def reset settings.replace(defaults) end |
#settings ⇒ Hash
Get the settings or initialize a new empty hash.
73 74 75 |
# File 'lib/dynamoid/config/options.rb', line 73 def settings @settings ||= {} end |