diff options
author | Christopher Brown <cb@opscode.com> | 2009-08-13 19:20:36 -0700 |
---|---|---|
committer | Christopher Brown <cb@opscode.com> | 2009-08-13 19:20:36 -0700 |
commit | cd3b25e79e07265ba5e38d566c0a505c3b46a781 (patch) | |
tree | e6de031e1f63951fafd57e0bdb5c932cd48566fd | |
parent | eaa6add1008f9f0df8d7d6760d2866f66a3210bd (diff) | |
download | mixlib-config-cd3b25e79e07265ba5e38d566c0a505c3b46a781.tar.gz |
fixing setting values in property/attribute form
-rw-r--r-- | lib/mixlib/config.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/lib/mixlib/config.rb b/lib/mixlib/config.rb index 30d45ac..7de4c34 100644 --- a/lib/mixlib/config.rb +++ b/lib/mixlib/config.rb @@ -36,10 +36,10 @@ module Mixlib end end - # Pass Mixlib::Config.configure() a block, and it will yield @configuration. + # Pass Mixlib::Config.configure() a block, and it will yield @@configuration. # # === Parameters - # <block>:: A block that takes @configure as it's argument + # <block>:: A block that is sent @@configuration as its argument def configure(&block) block.call(@@configuration) end @@ -142,18 +142,16 @@ module Mixlib # <ArgumentError>:: If the method_symbol does not match a configuration option. def method_missing(method_symbol, *args) num_args = args.length - - # If we have the symbol, or if we need to set it - if @@configuration.has_key?(method_symbol) || num_args > 0 - if num_args > 0 - internal_set(method_symbol, num_args == 1 ? args[0] : args) - end - return @@configuration[method_symbol] - else - # Otherwise, we're just looking it up - raise ArgumentError, "Cannot find configuration option #{method_symbol.to_s}" + + # Setting + if num_args > 0 + method_symbol = $1.to_sym unless (method_symbol.to_s =~ /(.+)=$/).nil? + @@configuration[method_symbol] = (num_args == 1 ? args[0] : args) end - end + + # Returning + @@configuration[method_symbol] + end end end |