Class | AppConfig::Base |
In: |
lib/app_config/base.rb
|
Parent: | Object |
The Base storage class. Acts as a wrapper for the different storage methods.
See each storage method‘s documentation for their specific options.
Valid storage methods:
TODO: Purge AppConfig options (ie, those not related to the user-end).
DEFAULTS | = | { :storage_method => :memory, } | TODO: All these DEFAULTS constants are kinda annoying. |
Accepts either a hash of options or a block (which overrides any options passed in the hash).
# File lib/app_config/base.rb, line 26 def initialize(options = {}, &block) @options = DEFAULTS.merge(options) yield @options if block_given? determine_storage_method if @options[:uri] @storage_method = initialize_storage_method @storage = @storage_method.data end
# File lib/app_config/base.rb, line 44 def []=(key, value) if storage.respond_to?(:[]=) storage[key] = value else raise AppConfig::Error::MustOverride.new('#[]=') end end
# File lib/app_config/base.rb, line 52 def empty? if storage.respond_to?(:empty?) storage.empty? else raise AppConfig::Error::MustOverride.new('#empty?') end end
# File lib/app_config/base.rb, line 60 def environment (@options[:environment] || @options[:env]) || nil end