Class: Puppet::Pops::Types::TypedModelObject

Inherits:
Object
  • Object
show all
Includes:
Adaptable, PuppetObject, Visitable
Defined in:
lib/puppet/pops/types/types.rb

Overview

The Types model is a model of Puppet Language types.

The TypeCalculator should be used to answer questions about types. The TypeFactory or TypeParser should be used to create an instance of a type whenever one is needed.

The implementation of the Types model contains methods that are required for the type objects to behave as expected when comparing them and using them as keys in hashes. (No other logic is, or should be included directly in the model's classes).

Direct Known Subclasses

PAnyType, PStructElement

Class Method Summary collapse

Methods included from Visitable

#accept

Methods included from PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_init_hash, #_pcore_type, #to_s

Class Method Details

._pcore_typeObject


48
49
50
# File 'lib/puppet/pops/types/types.rb', line 48

def self._pcore_type
  @type
end

.create_ptype(loader, ir, parent_name, attributes_hash = EMPTY_HASH) ⇒ Object


52
53
54
# File 'lib/puppet/pops/types/types.rb', line 52

def self.create_ptype(loader, ir, parent_name, attributes_hash = EMPTY_HASH)
  @type = Pcore::create_object_type(loader, ir, self, "Pcore::#{simple_name}Type", "Pcore::#{parent_name}", attributes_hash)
end

.register_ptypes(loader, ir) ⇒ Object


56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/puppet/pops/types/types.rb', line 56

def self.register_ptypes(loader, ir)
  types = [
    Annotation.register_ptype(loader, ir),
    RubyMethod.register_ptype(loader, ir),
  ]
  Types.constants.each do |c|
    next if c == :PType || c == :PHostClassType
    cls = Types.const_get(c)
    next unless cls.is_a?(Class) && cls < self
    type = cls.register_ptype(loader, ir)
    types << type unless type.nil?
  end
  types.each { |type| type.resolve(loader) }
end