Class: Puppet::DataTypes::TypeBuilderAPI

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

Overview

The TypeBuilderAPI class exposes only those methods that the builder API provides

Instance Method Summary collapse

Constructor Details

#initialize(type_builder) ⇒ TypeBuilderAPI

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 TypeBuilderAPI.


190
191
192
# File 'lib/puppet/datatypes.rb', line 190

def initialize(type_builder)
  @type_builder = type_builder
end

Instance Method Details

#implementation(&block) ⇒ Object

Raises:

  • (ArgumentError)

199
200
201
202
# File 'lib/puppet/datatypes.rb', line 199

def implementation(&block)
  raise ArgumentError, _('a data type can only have one implementation') if @type_builder.has_implementation?
  @type_builder.implementation = block
end

#implementation_class(ruby_class) ⇒ Object

Raises:

  • (ArgumentError)

204
205
206
207
# File 'lib/puppet/datatypes.rb', line 204

def implementation_class(ruby_class)
  raise ArgumentError, _('a data type can only have one implementation') if @type_builder.has_implementation?
  @type_builder.implementation_class = ruby_class
end

#interface(type_string) ⇒ Object

Raises:

  • (ArgumentError)

194
195
196
197
# File 'lib/puppet/datatypes.rb', line 194

def interface(type_string)
  raise ArgumentError, _('a data type can only have one interface') unless @type_builder.interface.nil?
  @type_builder.interface = type_string
end

#load_file(file_name) ⇒ Object


209
210
211
# File 'lib/puppet/datatypes.rb', line 209

def load_file(file_name)
  Puppet::Util::Autoload.load_file(file_name, Puppet.lookup(:current_environment))
end