Update stdlib and concat to 6.1.0 both
[mirror/dsa-puppet.git] / 3rdparty / modules / stdlib / lib / puppet / functions / to_yaml.rb
1 require 'yaml'
2 # @summary
3 #   Convert a data structure and output it as YAML
4 #
5 # @example how to output YAML
6 #   # output yaml to a file
7 #     file { '/tmp/my.yaml':
8 #       ensure  => file,
9 #       content => to_yaml($myhash),
10 #     }
11 Puppet::Functions.create_function(:to_yaml) do
12   # @param data
13   #
14   # @return [String]
15   dispatch :to_yaml do
16     param 'Any', :data
17   end
18
19   def to_yaml(data)
20     data.to_yaml
21   end
22 end