module AppConfig

Constants

VERSION

Public Class Methods

method_missing(name, *args) click to toggle source

Wrap `method_missing` to proxy to `storage`.

# File lib/app_config.rb, line 50
def method_missing(name, *args)
  storage.send(name.to_sym, *args)
end
reset!() click to toggle source

Clears the `@@storage`.

# File lib/app_config.rb, line 41
def reset!
  @@storage = nil
end
setup!(options = {}) { |storage| ... } click to toggle source

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)
  @@options = options

  if @@options[:yaml]
    @@storage = AppConfig::Storage::YAML.new(@@options.delete(:yaml))
  elsif @@options[:mongo]
    @@storage = AppConfig::Storage::Mongo.new(@@options.delete(:mongo))
  elsif @@options[:postgres]
    @@storage = AppConfig::Storage::Postgres.new(@@options.delete(:postgres))
  else
    @@storage = AppConfig::Storage::Base.new
  end

  yield @@storage if block_given?

  to_hash
end
setup?() click to toggle source

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

# File lib/app_config.rb, line 36
def setup?
  defined?(@@storage) && !@@storage.nil?
end
to_hash() click to toggle source
# File lib/app_config.rb, line 45
def to_hash
  storage ? storage.to_hash : {}
end

Private Class Methods

storage() click to toggle source

Returns the `@@storage` contents, which is what is exposed as the configuration.

# File lib/app_config.rb, line 57
def storage
  @@storage
end