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.



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

def initialize(type_builder)
  @type_builder = type_builder
end

Instance Method Details

#implementation(&block) ⇒ Object

Raises:

  • (ArgumentError)


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

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)


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

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)


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

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



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

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