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)
-
- (Hash) defaults
Get the defaults or initialize a new empty hash.
-
- (Object) option(name, options = {})
Define a configuration option with a default.
-
- (Hash) reset
Reset the configuration options to the defaults.
-
- (Hash) settings
Get the settings or initialize a new empty hash.
Instance Method Details
- (Hash) defaults
Get the defaults or initialize a new empty hash.
16 17 18 |
# File 'lib/dynamoid/config/options.rb', line 16 def defaults @defaults ||= {} end |
- (Object) option(name, options = {})
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 |
- (Hash) reset
Reset the configuration options to the defaults.
61 62 63 |
# File 'lib/dynamoid/config/options.rb', line 61 def reset settings.replace(defaults) end |
- (Hash) settings
Get the settings or initialize a new empty hash.
73 74 75 |
# File 'lib/dynamoid/config/options.rb', line 73 def settings @settings ||= {} end |