Class: EnvLoader::Configurator
- Inherits:
-
Object
- Object
- EnvLoader::Configurator
- Defined in:
- lib/env_loader/configurator.rb
Instance Attribute Summary collapse
-
#raw_config ⇒ Object
readonly
Returns the value of attribute raw_config.
Instance Method Summary collapse
- #config ⇒ Object
- #expose_values_as_environment_variables ⇒ Object
-
#initialize(config_file: nil, config_content: nil, config_subtree_key: nil) ⇒ Configurator
constructor
A new instance of Configurator.
Constructor Details
#initialize(config_file: nil, config_content: nil, config_subtree_key: nil) ⇒ Configurator
Returns a new instance of Configurator.
8 9 10 11 12 13 14 |
# File 'lib/env_loader/configurator.rb', line 8 def initialize(config_file: nil, config_content: nil, config_subtree_key: nil) if config_file @raw_config = config_from_file(config_file, config_subtree_key) elsif config_content @raw_config = config_from_content(config_content, config_subtree_key) end end |
Instance Attribute Details
#raw_config ⇒ Object (readonly)
Returns the value of attribute raw_config.
6 7 8 |
# File 'lib/env_loader/configurator.rb', line 6 def raw_config @raw_config end |
Instance Method Details
#config ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/env_loader/configurator.rb', line 16 def config raw_config.each_with_object({}) do |hash, new_hash| key, value = hash value = value.is_a?(Hash) ? value.to_json : value.to_s unless value.nil? new_hash[key.upcase] = value end end |
#expose_values_as_environment_variables ⇒ Object
24 25 26 |
# File 'lib/env_loader/configurator.rb', line 24 def expose_values_as_environment_variables config.each { |key, value| ENV[key] = value } end |