|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -# @summary |
4 | | -# Convert an object into a String containing its Ruby representation |
5 | | -# |
6 | | -# @example how to output Ruby |
7 | | -# # output Ruby to a file |
8 | | -# $listen = '0.0.0.0' |
9 | | -# $port = 8000 |
10 | | -# file { '/opt/acme/etc/settings.rb': |
11 | | -# content => inline_epp(@("SETTINGS")), |
12 | | -# LISTEN = <%= $listen.to_ruby %> |
13 | | -# PORT = <%= $mailserver.to_ruby %> |
14 | | -# | SETTINGS |
15 | | -# } |
| 3 | +# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims` |
16 | 4 |
|
| 5 | +# @summary DEPRECATED. Use the namespaced function [`stdlib::to_ruby`](#stdlibto_ruby) instead. |
17 | 6 | Puppet::Functions.create_function(:to_ruby) do |
18 | | - # @param object |
19 | | - # The object to be converted |
20 | | - # |
21 | | - # @return [String] |
22 | | - # The String representation of the object |
23 | | - dispatch :to_ruby do |
24 | | - param 'Any', :object |
| 7 | + dispatch :deprecation_gen do |
| 8 | + repeated_param 'Any', :args |
25 | 9 | end |
26 | | - |
27 | | - def to_ruby(object) |
28 | | - serialized = Puppet::Pops::Serialization::ToDataConverter.convert(object, rich_data: true) |
29 | | - serialized_to_ruby(serialized) |
30 | | - end |
31 | | - |
32 | | - def serialized_to_ruby(serialized) |
33 | | - case serialized |
34 | | - when Array then "[#{serialized.map { |x| serialized_to_ruby(x) }.join(', ')}]" |
35 | | - when Hash then "{#{serialized.map { |k, v| "#{serialized_to_ruby(k)} => #{serialized_to_ruby(v)}" }.join(', ')}}" |
36 | | - else serialized.inspect |
37 | | - end |
| 10 | + def deprecation_gen(*args) |
| 11 | + call_function('deprecation', 'to_ruby', 'This function is deprecated, please use stdlib::to_ruby instead.') |
| 12 | + call_function('stdlib::to_ruby', *args) |
38 | 13 | end |
39 | 14 | end |
0 commit comments