Every type must have at least one mandatory parameter: the namevar. This parameter will uniquely identify each resource of the type on the target system — for example, the path of a file on disk, the name of a user account, or the name of a package. If the user doesn’t specify a value for the namevar when declaring a resource, its value will default to the title of the resource. There are three ways to designate a namevar. Every type must have exactly one parameter that meets exactly one of these criteria:
Option 1: Create a parameter whose name is :name. Since most types just use :name as the namevar, it gets special treatment and will automatically become the namevar.
newparam(:name) do
desc "The name of the database."
endOption 2: Provide the :namevar => true option as an additional argument to the newparam call. This allows you to use a namevar with a different, more descriptive name (such as the file type’s path parameter).
newparam(:path, :namevar => true) do
...
endOption 3: Call the isnamevar method (which takes no arguments) inside the parameter’s code block. This allows you to use a namevar with a different, more descriptive name. There is no practical difference between this and option 2.
newparam(:path) do
isnamevar
...
end