Module: AppConfigLoader
- Defined in:
- lib/app_config_loader.rb,
lib/app_config_loader/config.rb,
lib/app_config_loader/errors.rb,
lib/app_config_loader/loader.rb,
lib/app_config_loader/parser.rb,
lib/app_config_loader/railtie.rb,
lib/app_config_loader/version.rb,
lib/app_config_loader/config_map.rb,
lib/app_config_loader/config_entry.rb,
lib/app_config_loader/config_with_indifferent_access.rb
Defined Under Namespace
Classes: Config, ConfigEntry, ConfigKeyConflict, ConfigMap, ConfigWithIndifferentAccess, InvalidConfigFile, InvalidConfigKey, Loader, Parser, Railtie
Constant Summary collapse
- VERSION =
'1.0.7'
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Configure the module.
-
.init ⇒ Object
Initialize the module This parse and load the app config into the constant specified by the configuration’s
const_nameproperty. -
.initialized? ⇒ Boolean
Whether the module has been initialized.
-
.load(config = nil) ⇒ AppConfigLoader::ConfigWithIndifferentAccess
Parse and load the app config.
Class Method Details
.configure {|config| ... } ⇒ Object
Configure the module
The block will be executed at during ::init
20 21 22 |
# File 'lib/app_config_loader.rb', line 20 def self.configure(&block) @cfg_blocks << block if block_given? end |
.init ⇒ Object
Initialize the module This parse and load the app config into the constant specified by the configuration’s const_name property
28 29 30 31 32 33 34 35 36 |
# File 'lib/app_config_loader.rb', line 28 def self.init self.run_config_blocks cfg = self.config raise NameError, "cannot assign app config because '#{cfg.const_name}' is already defined" if Object.const_defined?(cfg.const_name) Object.const_set cfg.const_name, self.load(self.config) @inited = true end |
.initialized? ⇒ Boolean
Whether the module has been initialized
41 42 43 |
# File 'lib/app_config_loader.rb', line 41 def self.initialized? !!@inited end |
.load(config = nil) ⇒ AppConfigLoader::ConfigWithIndifferentAccess
Parse and load the app config
61 62 63 64 |
# File 'lib/app_config_loader.rb', line 61 def self.load(config = nil) raise ArgumentError, 'config must be a AppConfigLoader::Config instance' unless config.nil? || config.is_a?(AppConfigLoader::Config) Loader.new(config || self.config).load end |