Class: AppConfig
- Inherits:
-
Object
- Object
- AppConfig
- Defined in:
- lib/app_config.rb
Direct Known Subclasses
Defined Under Namespace
Classes: ParsingError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(filename = "") ⇒ AppConfig
constructor
A new instance of AppConfig.
- #load ⇒ Object
Constructor Details
#initialize(filename = "") ⇒ AppConfig
Returns a new instance of AppConfig.
30 31 32 |
# File 'lib/app_config.rb', line 30 def initialize(filename = "") @filename = filename.empty? ? AppConfig.default_filename : filename end |
Class Method Details
.config_path_for(env) ⇒ Object
15 16 17 |
# File 'lib/app_config.rb', line 15 def config_path_for(env) "config/#{env}/config.json" end |
.default_filename ⇒ Object
11 12 13 |
# File 'lib/app_config.rb', line 11 def default_filename config_path_for(Environment.environment) end |
.load ⇒ Object
7 8 9 |
# File 'lib/app_config.rb', line 7 def load new(app_config_path).load end |
Instance Method Details
#load ⇒ Object
34 35 36 37 38 |
# File 'lib/app_config.rb', line 34 def load config['environment']&.each do |key, value| ENV[key] = value.is_a?(Hash) || value.is_a?(Array) ? value.to_json : value.to_s end end |