Module: AnywayAppConfig
- Defined in:
- lib/anyway_app_config.rb,
lib/anyway_app_config/config.rb,
lib/anyway_app_config/version.rb,
lib/anyway_app_config/singleton.rb,
lib/anyway_app_config/loaders/env_yaml.rb,
lib/anyway_app_config/loaders/flat_yaml.rb
Defined Under Namespace
Modules: Loaders, Singleton Classes: AlreadyLoadedError, Config, Error, NotLoadedError
Constant Summary collapse
- VERSION =
'0.3.2'
Class Method Summary collapse
-
.build(load: false, &block) ⇒ Object
Builds an anonymous AnywayAppConfig::Config subclass from a block, for use without a separate file.
Class Method Details
.build(load: false, &block) ⇒ Object
Builds an anonymous AnywayAppConfig::Config subclass from a block, for use without a separate file. The block is class_eval’d on the new subclass, so ‘config_name`, `env_prefix`, and `attribute` are available.
Returns the class by default; with ‘load: true` returns a frozen instance. Anonymous classes have no name, so `config_name` is mandatory in the block.
21 22 23 24 25 26 27 |
# File 'lib/anyway_app_config.rb', line 21 def self.build(load: false, &block) raise ArgumentError, 'AnywayAppConfig.build requires a block' unless block klass = Class.new(Config) klass.class_eval(&block) load ? klass.load! : klass end |