Method: Puppet::Pops::Types::PObjectType#initialize

Defined in:
lib/puppet/pops/types/p_object_type.rb

#initialize(name, init_hash_expression) ⇒ PObjectType #initialize(init_hash) ⇒ PObjectType

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.

Initialize an Object Type instance. The initialization will use either a name and an initialization hash expression, or a fully resolved initialization hash.

Overloads:

  • #initialize(name, init_hash_expression) ⇒ PObjectType

    Used when the Object type is loaded using a type alias expression. When that happens, it is important that the actual resolution of the expression is deferred until all definitions have been made known to the current loader. The object will then be resolved when it is loaded by the TypeParser. “resolved” here, means that the hash expression is fully resolved, and then passed to the #_pcore_init_from_hash method.

  • #initialize(init_hash) ⇒ PObjectType

    Used when the object is created by the TypeFactory. The init_hash must be fully resolved.



441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/puppet/pops/types/p_object_type.rb', line 441

def initialize(_pcore_init_hash, init_hash_expression = nil) # rubocop:disable Lint/UnderscorePrefixedVariableName
  if _pcore_init_hash.is_a?(Hash)
    _pcore_init_from_hash(_pcore_init_hash)
    @loader = init_hash_expression unless init_hash_expression.nil?
  else
    @type_parameters = EMPTY_HASH
    @attributes = EMPTY_HASH
    @functions = EMPTY_HASH
    @name = TypeAsserter.assert_instance_of('object name', TYPE_OBJECT_NAME, _pcore_init_hash)
    @init_hash_expression = init_hash_expression
  end
end