lib/dynamoid/config/options.rb in dynamoid-0.0.2 vs lib/dynamoid/config/options.rb in dynamoid-0.0.3

- old
+ new

@@ -1,6 +1,6 @@ -# encoding: utf-8 +# Shamelessly stolen from Mongoid! module Dynamoid #:nodoc module Config # Encapsulates logic for setting options. module Options @@ -9,12 +9,10 @@ # # @example Get the defaults. # options.defaults # # @return [ Hash ] The default options. - # - # @since 2.3.0 def defaults @defaults ||= {} end # Define a configuration option with a default. @@ -24,12 +22,10 @@ # # @param [ Symbol ] name The name of the configuration option. # @param [ Hash ] options Extras for the option. # # @option options [ Object ] :default The default value. - # - # @since 2.0.0.rc.1 def option(name, options = {}) defaults[name] = settings[name] = options[:default] class_eval <<-RUBY def #{name} @@ -41,32 +37,32 @@ end def #{name}? #{name} end + + def reset_#{name} + settings[#{name.inspect}] = defaults[#{name.inspect}] + end RUBY end # Reset the configuration options to the defaults. # # @example Reset the configuration options. # config.reset # # @return [ Hash ] The defaults. - # - # @since 2.3.0 def reset settings.replace(defaults) end # Get the settings or initialize a new empty hash. # # @example Get the settings. # options.settings # # @return [ Hash ] The setting options. - # - # @since 2.3.0 def settings @settings ||= {} end end end