Method: Puppet::DataTypes::TypeBuilder#create_type

Defined in:
lib/puppet/datatypes.rb

#create_type(loader) ⇒ 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.

Raises:

  • (ArgumentError)


155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/puppet/datatypes.rb', line 155

def create_type(loader)
  raise ArgumentError, _('a data type must have an interface') unless @interface.is_a?(String)
  created_type = Puppet::Pops::Types::PObjectType.new(
    @type_name,
    Puppet::Pops::Parser::EvaluatingParser.new.parse_string("{ #{@interface} }").body)

  if !@implementation_class.nil?
    if @implementation_class < Puppet::Pops::Types::PuppetObject
      @implementation_class.instance_eval do
        include Puppet::Pops::Types::PuppetObject
        @_pcore_type = created_type

        def self._pcore_type
          @_pcore_type
        end
      end
    else
      Puppet::Pops::Loaders.implementation_registry.register_implementation(created_type, @implementation_class)
    end
    created_type.implementation_class = @implementation_class
  elsif !@implementation.nil?
    created_type.implementation_override = @implementation
  end
  created_type
end