Method: Puppet::Pops::Types::PMetaType#resolve

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

#resolve(loader) ⇒ PTypeAliasType

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.

Called from the TypeParser once it has found a type using the Loader. The TypeParser will interpret the contained expression and the resolved type is remembered. This method also checks and remembers if the resolve type contains self recursion.

Parameters:

  • type_parser (TypeParser)

    type parser that will interpret the type expression

  • loader (Loader::Loader)

    loader to use when loading type aliases

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/puppet/pops/types/p_meta_type.rb', line 37

def resolve(loader)
  unless @init_hash_expression.nil?
    @loader = loader
    @self_recursion = true # assumed while it being found out below

    init_hash_expression = @init_hash_expression
    @init_hash_expression = nil
    if init_hash_expression.is_a?(Model::LiteralHash)
      init_hash = resolve_literal_hash(loader, init_hash_expression)
    else
      init_hash = resolve_hash(loader, init_hash_expression)
    end
    _pcore_init_from_hash(init_hash)

    # Find out if this type is recursive. A recursive type has performance implications
    # on several methods and this knowledge is used to avoid that for non-recursive
    # types.
    guard = RecursionGuard.new
    accept(NoopTypeAcceptor::INSTANCE, guard)
    @self_recursion = guard.recursive_this?(self)
  end
  self
end