Module: Configoro
- Defined in:
- lib/configoro/base.rb,
lib/configoro.rb,
lib/configoro/hash.rb
Overview
This module handles initialization of the Configoro object, and contains some utility methods.
Defined Under Namespace
Classes: Hash, HashWithIndifferentAccess, Railtie
Class Method Summary collapse
-
.initialize ⇒ Object
Creates the configuration dictionary and stores it under ‘MyApp::Configuration` (assuming an application named `MyApp`).
-
.load_environment(env) ⇒ Configoro::Hash
Loads the configuration for an environment and returns it as a Hash.
-
.paths ⇒ Array<String>
The search paths Configoro uses to locate configuration files.
-
.reset_paths ⇒ Object
Resets any custom configuration paths set using Configoro.paths.
Class Method Details
.initialize ⇒ Object
Creates the configuration dictionary and stores it under ‘MyApp::Configuration` (assuming an application named `MyApp`).
9 10 11 |
# File 'lib/configoro/base.rb', line 9 def self.initialize namespace.const_set :Configuration, load_environment(Rails.env) end |
.load_environment(env) ⇒ Configoro::Hash
Loads the configuration for an environment and returns it as a Hash. Use this method to access Configoro options outside the context of your Rails app. You will need to configure paths first (see example).
55 56 57 58 59 |
# File 'lib/configoro/base.rb', line 55 def self.load_environment(env) config = Configoro::Hash.new load_data config, env config end |
.paths ⇒ Array<String>
The search paths Configoro uses to locate configuration files. By default this list contains one item, ‘RAILS_ROOT/config/environments`. You can edit this list to add your own search paths. Any such paths should have subdirectories for each environment, and `common`, as expected by Configoro.
Be sure to add paths before the Configoro initializer is called (see the example).
Paths are processed in the order they appear in this array.
30 31 32 33 34 35 36 |
# File 'lib/configoro/base.rb', line 30 def self.paths @paths ||= begin paths = [] paths << "#{Rails.root}/config/environments" if defined?(Rails) paths end end |
.reset_paths ⇒ Object
Resets any custom configuration paths set using paths.
40 41 42 |
# File 'lib/configoro/base.rb', line 40 def self.reset_paths remove_instance_variable :@paths end |