Class: Puppet::DataTypes::TypeBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/datatypes.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

API:

  • private

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type_name) ⇒ TypeBuilder

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.

Returns a new instance of TypeBuilder.

API:

  • private



149
150
151
152
153
# File 'lib/puppet/datatypes.rb', line 149

def initialize(type_name)
  @type_name = type_name
  @implementation = nil
  @implementation_class = nil
end

Instance Attribute Details

#implementationObject

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.

API:

  • private



147
148
149
# File 'lib/puppet/datatypes.rb', line 147

def implementation
  @implementation
end

#implementation_classObject

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.

API:

  • private



147
148
149
# File 'lib/puppet/datatypes.rb', line 147

def implementation_class
  @implementation_class
end

#interfaceObject

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.

API:

  • private



147
148
149
# File 'lib/puppet/datatypes.rb', line 147

def interface
  @interface
end

Instance Method Details

#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:

API:

  • private



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
180
181
# 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

#has_implementation?Boolean

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.

Returns:

API:

  • private



183
184
185
# File 'lib/puppet/datatypes.rb', line 183

def has_implementation?
  !(@implementation_class.nil? && @implementation.nil?)
end