Class: BlueprintConfig::Backend::YAML

Inherits:
Base
  • Object
show all
Defined in:
lib/blueprint_config/backend/yaml.rb

Instance Method Summary collapse

Methods inherited from Base

#fresh?, #nest_hash, #source

Constructor Details

#initialize(path = 'config/app.yml') ⇒ YAML

Returns a new instance of YAML.



10
11
12
# File 'lib/blueprint_config/backend/yaml.rb', line 10

def initialize(path = 'config/app.yml')
  @path = path
end

Instance Method Details

#load_keysObject



14
15
16
17
18
19
20
21
# File 'lib/blueprint_config/backend/yaml.rb', line 14

def load_keys
  if File.exist?(path)
    parsed = ::YAML.load(File.read(path), aliases: true).deep_symbolize_keys
    parsed.fetch(:default, {}).deep_merge(parsed.fetch(BlueprintConfig.env&.to_sym, {}))
  else
    {}
  end
end