Class: Dry::Credentials::YAML

Inherits:
Object
  • Object
show all
Defined in:
lib/dry/credentials/yaml.rb

Defined Under Namespace

Classes: Query

Instance Method Summary collapse

Constructor Details

#initialize(yaml) ⇒ YAML

Returns a new instance of YAML.

Parameters:

  • string (String)

    YAML document content



8
9
10
11
12
13
14
# File 'lib/dry/credentials/yaml.rb', line 8

def initialize(yaml)
  @yaml = yaml
  @hash = ::YAML.safe_load yaml
  fail Dry::Credentials::YAMLFormatError unless @hash.instance_of? Hash
rescue Psych::DisallowedClass
  raise Dry::Credentials::YAMLFormatError
end

Instance Method Details

#inject_into(object) ⇒ Array

Define readers for the first level of the credentials on the given object.

Parameters:

  • object (Object)

    to inject the methods into

Returns:

  • (Array)

    injected methods



21
22
23
# File 'lib/dry/credentials/yaml.rb', line 21

def inject_into(object)
  Query.new(@hash).send(:inject_into, object)
end