Method: Puppet::Pal::Compiler#create

Defined in:
lib/puppet/pal/compiler.rb

#create(data_type, *arguments) ⇒ 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.

Creates a new instance of a given data type.

Parameters:

  • data_type (String, Puppet::Pops::Types::PAnyType)

    the data type as a data type or in String form.

  • arguments (Object)

    one or more arguments to the called ‘new` function

Returns:

  • (Object)

    an instance of the given data type, or raises an error if it was not possible to parse data type or create an instance.



188
189
190
191
192
193
194
# File 'lib/puppet/pal/compiler.rb', line 188

def create(data_type, *arguments)
  t = data_type.is_a?(String) ? type(data_type) : data_type
  unless t.is_a?(Puppet::Pops::Types::PAnyType)
    raise ArgumentError, _("Given data_type value is not a data type, got '%{type}'") % {type: t.class}
  end
  call_function('new', t, *arguments)
end