Class: EnvConfiguration::Adapter::YamlAdapter
- Inherits:
-
Base
- Object
- Base
- EnvConfiguration::Adapter::YamlAdapter
show all
- Defined in:
- lib/env_configuration/adapter/yaml_adapter.rb
Instance Method Summary
collapse
Methods inherited from Base
#update_env_variable_with
Constructor Details
#initialize(options = {}) ⇒ YamlAdapter
Returns a new instance of YamlAdapter.
7
8
9
|
# File 'lib/env_configuration/adapter/yaml_adapter.rb', line 7
def initialize(options = {})
super(options)
end
|
Instance Method Details
#fetch_configs ⇒ Object
29
30
31
|
# File 'lib/env_configuration/adapter/yaml_adapter.rb', line 29
def fetch_configs
::YAML.load_file(yaml_file)[section]
end
|
#load ⇒ Object
23
24
25
26
27
|
# File 'lib/env_configuration/adapter/yaml_adapter.rb', line 23
def load
configs = fetch_configs
update_env_variable_with(configs)
configs
end
|
#section ⇒ Object
11
12
13
14
15
|
# File 'lib/env_configuration/adapter/yaml_adapter.rb', line 11
def section
section_value = @options[:section] || EnvConfiguration.configuration.yaml_section
raise ":section in the options{} is required, for example :staging, :test, :production" if section_value.nil?
section_value
end
|
#yaml_file ⇒ Object
17
18
19
20
21
|
# File 'lib/env_configuration/adapter/yaml_adapter.rb', line 17
def yaml_file
yaml_file_value = @options[:yaml_file] || EnvConfiguration.configuration.yaml_file
raise ":yaml_file in the options{} is required, for example config/application.yml" if yaml_file_value.nil?
yaml_file_value
end
|