Method: Puppet::Pops::Loader::TypeDefinitionInstantiator.create_named_type

Defined in:
lib/puppet/pops/loader/type_definition_instantiator.rb

.create_named_type(name, type_name, type_expr, name_authority) ⇒ 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.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/puppet/pops/loader/type_definition_instantiator.rb', line 75

def self.create_named_type(name, type_name, type_expr, name_authority)
  case type_name
  when 'Object'
    # No need for an alias. The Object type itself will receive the name instead
    unless type_expr.is_a?(Model::LiteralHash)
      type_expr = type_expr.keys.empty? ? nil : type_expr.keys[0] unless type_expr.is_a?(Hash)
    end
    Types::PObjectType.new(name, type_expr)
  when 'TypeSet'
    # No need for an alias. The Object type itself will receive the name instead
    type_expr = type_expr.keys.empty? ? nil : type_expr.keys[0] unless type_expr.is_a?(Hash)
    Types::PTypeSetType.new(name, type_expr, name_authority)
  else
    Types::PTypeAliasType.new(name, type_expr)
  end
end