Class: Konfig::Sources::YAML

Inherits:
Abstract show all
Defined in:
lib/konfig/sources/yaml.rb

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ YAML

Returns a new instance of YAML.



11
12
13
14
# File 'lib/konfig/sources/yaml.rb', line 11

def initialize(source)
  super()
  @source = ::YAML.safe_load(source)
end

Instance Method Details

#get(path, attribute: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



17
18
19
20
21
22
23
24
25
# File 'lib/konfig/sources/yaml.rb', line 17

def get(path, attribute: nil)
  source = @source
  path.each do |p|
    raise ValueNotPresentError unless source.key?(p.to_s)

    source = source[p.to_s]
  end
  source
end