Namespace

AppConfig

Constants

VERSION

Public Class Methods

[](key) click to toggle source

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
[]=(key, value) click to toggle source

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
empty?() click to toggle source
# 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
reset!() click to toggle source

Clears the `@@storage`.

# File lib/app_config.rb, line 40
def reset!
  if defined?(@@storage)
    remove_class_variable(:@@storage)
    true
  else
    false
  end
end
setup(options = {}, &block) click to toggle source

Accepts an `options` hash or a block. See each storage method's documentation for their specific options.

Valid storage methods:

# 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
setup?() click to toggle source

Returns `true` if {AppConfig.setup AppConfig.setup} has been called.

# File lib/app_config.rb, line 35
def setup?
  !!(defined?(@@storage) && !@@storage.empty?)
end
to_hash() click to toggle source
# File lib/app_config.rb, line 68
def to_hash
  unless setup?
    @@storage = default_storage
  end

  storage.to_hash
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.