Method: Puppet::Pops::Pcore.create_object_type

Defined in:
lib/puppet/pops/pcore.rb

.create_object_type(loader, ir, impl_class, type_name, parent_name, attributes_hash = EMPTY_HASH, functions_hash = EMPTY_HASH, equality = nil) ⇒ 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.

Create and register a new ‘Object` type in the Puppet Type System and map it to an implementation class

Parameters:

  • loader (Loader::Loader)

    The loader where the new type will be registered

  • ir (ImplementationRegistry)

    The implementation registry that maps this class to the new type

  • impl_class (Class)

    The class that is the implementation of the type

  • type_name (String)

    The fully qualified name of the new type

  • parent_name (String, nil)

    The fully qualified name of the parent type

  • attributes_hash (Hash{String => Object}) (defaults to: EMPTY_HASH)

    A hash of attribute definitions for the new type

  • functions_hash (Hash{String => Object}) (defaults to: EMPTY_HASH)

    A hash of function definitions for the new type

  • equality (Array<String>) (defaults to: nil)

    An array with names of attributes that participate in equality comparison

Returns:

  • (PObjectType)

    the created type. Not yet resolved



102
103
104
105
106
107
108
109
110
# File 'lib/puppet/pops/pcore.rb', line 102

def self.create_object_type(loader, ir, impl_class, type_name, parent_name, attributes_hash = EMPTY_HASH, functions_hash = EMPTY_HASH, equality = nil)
  init_hash = {}
  init_hash[Types::KEY_PARENT] = Types::PTypeReferenceType.new(parent_name) unless parent_name.nil?
  init_hash[Types::KEY_ATTRIBUTES] = attributes_hash unless attributes_hash.empty?
  init_hash[Types::KEY_FUNCTIONS] = functions_hash unless functions_hash.empty?
  init_hash[Types::KEY_EQUALITY] = equality unless equality.nil?
  ir.register_implementation(type_name, impl_class)
  add_type(Types::PObjectType.new(type_name, init_hash), loader)
end