Module: AppConfig

Defined in:
lib/app-config.rb,
lib/app-config/railtie.rb,
lib/app-config/version.rb

Overview

Public: Application Configuration singleton. Config is stored within as a class

Defined Under Namespace

Classes: Config, Configuration, Error, Railtie

Constant Summary collapse

VERSION =
"1.0.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configurationObject

Returns the value of attribute configuration.



47
48
49
# File 'lib/app-config.rb', line 47

def configuration
  @configuration
end

Class Method Details

.configure {|configuration| ... } ⇒ Object

Public: Configure AppConfig. Note that repeated calls to configure will reset all configuration and clear the existing config class. Therefore you need to configure AppConfig all in one go, or alternatively access configuration parameters directly e.g. AppConfig.configuration.config_file

Yields to the provided block, then sets defaults on top.

Yields:



56
57
58
59
60
61
# File 'lib/app-config.rb', line 56

def self.configure(&block)
  self.configuration = Configuration.new
  @klass = nil
  yield(configuration)
  self.configuration.defaults
end

.method_missing(method, *args, &block) ⇒ Object



81
82
83
84
85
86
87
88
# File 'lib/app-config.rb', line 81

def self.method_missing(method, *args, &block)
  if @klass || self.configuration.config_file
    @klass ||= Config.new(self.configuration)
    @klass.__send__(method, *args, &block)
  else
    raise Error, "Please set a config_file with AppConfig.configure first"
  end
end