Module: NitroConfig
- Defined in:
- lib/nitro_config.rb,
lib/nitro_config/error.rb,
lib/nitro_config/rspec.rb,
lib/nitro_config/options.rb,
lib/nitro_config/railtie.rb,
lib/nitro_config/version.rb
Overview
When included in a Rails application, NitroConfig loads the configuration file at ‘config/config.yml` within the application directory and makes its values available at NitroConfig.config.
Config values are loaded based on the Rails environment, permitting the specification of multiple environments’ configurations in a single file.
Defined Under Namespace
Modules: Rspec Classes: Error, Options
Constant Summary collapse
- PATH_SEPARATOR =
"/"
- VERSION =
"0.2.0"
Class Method Summary collapse
-
.config ⇒ NitroConfig::Options
Provides the loaded global configuration.
- .get(*args) ⇒ Object
- .get!(*args) ⇒ Object
-
.get_deferred!(*args) ⇒ Proc
Returns a function that will return the requested config when invoked.
-
.load!(file, env) ⇒ NitroConfig::Options
Loads a configuration file as the global config, making it accessible via NitroConfig.config.
Class Method Details
.config ⇒ NitroConfig::Options
Provides the loaded global configuration
30 31 32 |
# File 'lib/nitro_config.rb', line 30 def self.config @config ||= NitroConfig::Options.new end |
.get(*args) ⇒ Object
35 36 37 |
# File 'lib/nitro_config.rb', line 35 def self.get(*args) config.get(*args) end |
.get!(*args) ⇒ Object
40 41 42 |
# File 'lib/nitro_config.rb', line 40 def self.get!(*args) config.get!(*args) end |
.get_deferred!(*args) ⇒ Proc
Returns a function that will return the requested config when invoked. This method is useful for fetching configurations in declarative contexts where the code will be invoked in boot time. This will defer the fetching of the config to when needed.
50 51 52 |
# File 'lib/nitro_config.rb', line 50 def self.get_deferred!(*args) ->(*_args) { config.get!(*args) } end |
.load!(file, env) ⇒ NitroConfig::Options
Loads a configuration file as the global config, making it accessible via config
23 24 25 |
# File 'lib/nitro_config.rb', line 23 def self.load!(file, env) @config = NitroConfig::Options.load_yml(file, env) end |