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.



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

def initialize(type_builder)
  @type_builder = type_builder
end

Instance Method Details

#implementation(&block) ⇒ Object

Raises:

  • (ArgumentError)


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

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)


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

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)


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

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



215
216
217
# File 'lib/puppet/datatypes.rb', line 215

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