Access the configured `key`'s value.
# File lib/app_config.rb, line 50 def [](key) warn "DEPRECATED: AppConfig.[] is deprecated and will be removed in 2.0." setup unless setup? storage[key] end
Set a new `value` for `key` (persistence depends on the type of Storage).
# File lib/app_config.rb, line 57 def []=(key, value) warn "DEPRECATED: AppConfig.[]= is deprecated and will be removed in 2.0." setup unless setup? storage[key] = value end
# File lib/app_config.rb, line 63 def empty? warn "DEPRECATED: AppConfig.empty? is deprecated and will be removed in 2.0." storage.empty? end
Clears the `@@storage`.
# File lib/app_config.rb, line 40 def reset! if defined?(@@storage) remove_class_variable(:@@storage) true else false end end
Accepts an `options` hash or a block. See each storage method's documentation for their specific options.
Valid storage methods:
`:mongo` - {AppConfig::Storage::Mongo AppConfig::Storage::Mongo}
`:yaml` - {AppConfig::Storage::YAML AppConfig::Storage::YAML}
# File lib/app_config.rb, line 17 def setup(options = {}, &block) warn "DEPRECATED: AppConfig.setup will be renamed to AppConfig.setup! in 2.0." @@options = options if @@options[:yaml] @@storage = AppConfig::Storage::YAML.new(@@options.delete(:yaml)) elsif @@options[:mongo] @@storage = AppConfig::Storage::Mongo.new(@@options.delete(:mongo)) else @@storage = Hash.new(&Storage::DEEP_HASH) end yield @@storage if block_given? to_hash end
Returns `true` if {AppConfig.setup AppConfig.setup} has been called.
# File lib/app_config.rb, line 35 def setup? !!(defined?(@@storage) && !@@storage.empty?) end
Generated with the Darkfish Rdoc Generator 2.