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.



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

def initialize(type_builder)
  @type_builder = type_builder
end

Instance Method Details

#implementation(&block) ⇒ Object

Raises:

  • (ArgumentError)


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

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)


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

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)


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

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



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

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