官术网_书友最值得收藏!

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
主站蜘蛛池模板: 胶州市| 临邑县| 福贡县| 扎赉特旗| 淮滨县| 浙江省| 文水县| 晴隆县| 克什克腾旗| 河曲县| 封丘县| 湾仔区| 临邑县| 加查县| 沙田区| 汉寿县| 图们市| 芦山县| 花莲市| 乐平市| 渝中区| 玉屏| 修水县| 湖北省| 万州区| 乡城县| 永胜县| 英吉沙县| 依安县| 阿城市| 滦平县| 庄浪县| 隆化县| 蒙城县| 商水县| 滁州市| 定陶县| 兰西县| 睢宁县| 文化| 长兴县|