Method: Puppet::Pops::Types::PObjectType#create_init_hash_type

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

#create_init_hash_typePStructType

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 the type that a initialization hash used for creating instances of this type must conform to.

Returns:

  • the initialization hash type

API:

  • private



875
876
877
878
879
880
881
882
883
884
885
886
887
# File 'lib/puppet/pops/types/p_object_type.rb', line 875

def create_init_hash_type
  struct_elems = {}
  attributes(true).values.each do |attr|
    unless attr.kind == ATTRIBUTE_KIND_CONSTANT || attr.kind == ATTRIBUTE_KIND_DERIVED
      if attr.value?
        struct_elems[TypeFactory.optional(attr.name)] = attr.type
      else
        struct_elems[attr.name] = attr.type
      end
    end
  end
  TypeFactory.struct(struct_elems)
end