- From: Andrea Campi <
>
- To:
- Subject: [chef] Re: Deleting an element in an attribute?
- Date: Thu, 2 Feb 2012 08:30:31 +0100
On Thu, Feb 2, 2012 at 1:05 AM, Robert Keng
<
>
wrote:
>
I'm probably not using the right terms, but lets' say I have the following:
>
>
set[:packages_install_specific] = [
>
["js","1.70-8"],
>
["icu","3.6-5.16.1"],
>
["libicu","3.6-5.16.1"],
>
["libicu-devel","3.6-5.16.1"]
>
]
>
>
The attrs looks like:
>
{
>
"normal": {
>
"packages_install_specific": [
>
[
>
"js",
>
"1.70-8"
>
],
>
[
>
"icu",
>
"3.6-5.16.1"
>
],
>
[
>
"libicu",
>
"3.6-5.16.1"
>
],
>
[
>
"libicu-devel",
>
"3.6-5.16.1"
>
]
>
]
>
>
...
>
>
Is it possible to delete the tuple ["libicu-devel","3.6-5.16.1"]
>
programmatically in a recipe? I've tried using:
There are more idiomatic ways that are more compact, but this is nice
and readable:
packages = node[:packages_install_specific]
packages.reject! do |name, version|
name == "libicu-devel" && version == "3.6-5.16.1"
end
node[:packages_install_specific] = packages
Andrea
Archive powered by MHonArc 2.6.16.