Method: Puppet::DataTypes.create_type

Defined in:
lib/puppet/datatypes.rb

.create_type(type_name, &block) ⇒ Object



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/puppet/datatypes.rb', line 124

def self.create_type(type_name, &block)
  # Ruby < 2.1.0 does not have method on Binding, can only do eval
  # and it will fail unless protected with an if defined? if the local
  # variable does not exist in the block's binder.
  #
  begin
    loader = block.binding.eval('loader_injected_arg if defined?(loader_injected_arg)')
    create_loaded_type(type_name, loader, &block)
  rescue StandardError => e
    raise ArgumentError, _("Data Type Load Error for type '%{type_name}': %{message}") % {type_name: type_name, message: e.message}
  end

end