Puppet Function: to_yaml

Defined in:
lib/puppet/functions/to_yaml.rb
Function type:
Ruby 4.x API

Overview

Signatures:

  • to_yaml(Hash $hash)Any

    Parameters:

    • hash (Hash)

    Returns:

    • (Any)
  • to_yaml(Array $array)Any

    Parameters:

    • array (Array)

    Returns:

    • (Any)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/puppet/functions/to_yaml.rb', line 3

Puppet::Functions.create_function(:to_yaml) do
  dispatch :hash_to_yaml do
    param 'Hash', :hash
  end

  dispatch :array_to_yaml do
    param 'Array', :array
  end

  def hash_to_yaml(hash)
    yaml = "%YAML 1.1\n"
    yaml << hash.to_yaml
  end

  def array_to_yaml(array)
    yaml = "%YAML 1.1\n"
    yaml << array.to_yaml
  end
end