Checking datatype compatibility with munge

To decide whether an underlying provider property should be updated, a simple equality comparison is made between the provided value and the value retrieved using the provider.

The munge method can ensure that the data supplied by the user has a consistent datatype with that expected to be returned from the provider. For example, we could call the munge method to make sure that the user-supplied datatype of integer or numeric string is compatible with the integer required by the provider, as shown in the following code:

Puppet::Type.newtype(:mynewtype) do
...
newparam(:identifier) do
munge do |value|
Integer(value)
end
end
...
end
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.120.109