def newtype(name, options = {}, &block)
    # Handle backward compatibility
    unless options.is_a?(Hash)
      #TRANSLATORS 'Puppet::Type.newtype' should not be translated
      Puppet.warning(_("Puppet::Type.newtype(%{name}) now expects a hash as the second argument, not %{argument}") %
                         { name: name, argument: options.inspect})
    end

    # First make sure we don't have a method sitting around
    name = name.intern
    newmethod = "new#{name}"

    # Used for method manipulation.
    selfobj = singleton_class

    @types ||= {}

    if @types.include?(name)
      if self.respond_to?(newmethod)
        # Remove the old newmethod
        selfobj.send(:remove_method,newmethod)
      end
    end

    # Then create the class.

    klass = genclass(
      name,
      :parent => Puppet::Type,
      :overwrite => true,
      :hash => @types,
      :attributes => options,
      &block
    )

    # Now define a "new<type>" method for convenience.
    if self.respond_to? newmethod
      # Refuse to overwrite existing methods like 'newparam' or 'newtype'.
      #TRANSLATORS 'new%{method}' will become a method name, do not translate this string
      Puppet.warning(_("'new%{method}' method already exists; skipping") % { method: name.to_s })
    else
      selfobj.send(:define_method, newmethod) do |*args|
        klass.new(*args)
      end
    end

    # If they've got all the necessary methods defined and they haven't
    # already added the property, then do so now.
    klass.ensurable if klass.ensurable? and ! klass.validproperty?(:ensure)

    # Now set up autoload any providers that might exist for this type.

    klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name.to_s}")

    # We have to load everything so that we can figure out the default provider.
    klass.providerloader.loadall(Puppet.lookup(:current_environment))
    klass.providify unless klass.providers.empty?

    loc = block_given? ? block.source_location : nil
    uri = loc.nil? ? nil : URI("#{Puppet::Util.path_to_uri(loc[0])}?line=#{loc[1]}")
    Puppet::Pops::Loaders.register_runtime3_type(name, uri)

    klass
  end
def newtype(name, options = {}, &block)
    # Handle backward compatibility
    unless options.is_a?(Hash)
      #TRANSLATORS 'Puppet::Type.newtype' should not be translated
      Puppet.warning(_("Puppet::Type.newtype(%{name}) now expects a hash as the second argument, not %{argument}") %
                         { name: name, argument: options.inspect})
    end

    # First make sure we don't have a method sitting around
    name = name.intern
    newmethod = "new#{name}"

    # Used for method manipulation.
    selfobj = singleton_class

    @types ||= {}

    if @types.include?(name)
      if self.respond_to?(newmethod)
        # Remove the old newmethod
        selfobj.send(:remove_method,newmethod)
      end
    end

    # Then create the class.

    klass = genclass(
      name,
      :parent => Puppet::Type,
      :overwrite => true,
      :hash => @types,
      :attributes => options,
      &block
    )

    # Now define a "new<type>" method for convenience.
    if self.respond_to? newmethod
      # Refuse to overwrite existing methods like 'newparam' or 'newtype'.
      #TRANSLATORS 'new%{method}' will become a method name, do not translate this string
      Puppet.warning(_("'new%{method}' method already exists; skipping") % { method: name.to_s })
    else
      selfobj.send(:define_method, newmethod) do |*args|
        klass.new(*args)
      end
    end

    # If they've got all the necessary methods defined and they haven't
    # already added the property, then do so now.
    klass.ensurable if klass.ensurable? and ! klass.validproperty?(:ensure)

    # Now set up autoload any providers that might exist for this type.

    klass.providerloader = Puppet::Util::Autoload.new(klass, "puppet/provider/#{klass.name.to_s}")

    # We have to load everything so that we can figure out the default provider.
    klass.providerloader.loadall(Puppet.lookup(:current_environment))
    klass.providify unless klass.providers.empty?

    loc = block_given? ? block.source_location : nil
    uri = loc.nil? ? nil : URI("#{Puppet::Util.path_to_uri(loc[0])}?line=#{loc[1]}")
    Puppet::Pops::Loaders.register_runtime3_type(name, uri)

    klass
  end
Defines a new type or redefines an existing type with the given name.
 A convenience method on the form `new<name>` where name is the name of the type is also created.
 (If this generated method happens to clash with an existing method, a warning is issued and the original
 method is kept).

 @param name [String] the name of the type to create or redefine.
 @param options [Hash] options passed on to {Puppet::Util::ClassGen#genclass} as the option `:attributes`.
 @option options [Puppet::Type]
   Puppet::Type. This option is not passed on as an attribute to genclass.
 @yield [ ] a block evaluated in the context of the created class, thus allowing further detailing of
   that class.
 @return [Class<inherits Puppet::Type>] the created subclass
 @see Puppet::Util::ClassGen.genclass

 @dsl type
 @api public