Method: Qonfig::Loaders::YAML.load

Defined in:
lib/qonfig/loaders/yaml.rb

.load(data) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • data (String)

Returns:

  • (Object)

Raises:

Since:

  • 0.2.0

Version:

  • 0.27.0



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/qonfig/loaders/yaml.rb', line 15

def load(data)
  yaml = ERB.new(data).result
  ::YAML.respond_to?(:unsafe_load) ? ::YAML.unsafe_load(yaml) : ::YAML.load(yaml)
rescue ::Psych::SyntaxError => error
  raise(
    Qonfig::YAMLLoaderParseError.new(
      error.file,
      error.line,
      error.column,
      error.offset,
      error.problem,
      error.context
    ).tap { |exception| exception.set_backtrace(error.backtrace) }
  )
end