diff options
author | Thom May <thom@may.lt> | 2016-08-27 11:00:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-27 11:00:55 +0100 |
commit | 5af6e50e0e36d4b737a1e17c5897f853bf5f0914 (patch) | |
tree | b5cdd55acb447ef8c04afd1ca7634095eac97130 | |
parent | a2d97bc74c78bdf6ce395bae0db64e5a5f95d81b (diff) | |
parent | 3ada1ab1436d52deda5237be264e0dd3e9eaf584 (diff) | |
download | chef-5af6e50e0e36d4b737a1e17c5897f853bf5f0914.tar.gz |
Merge pull request #5258 from jaymzh/fix_yum_perf
Fix flush_cache issues in yum_package
-rw-r--r-- | lib/chef/resource/yum_package.rb | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb index 1f749b93c0..9d69897f5f 100644 --- a/lib/chef/resource/yum_package.rb +++ b/lib/chef/resource/yum_package.rb @@ -27,18 +27,19 @@ class Chef # Install a specific arch property :arch, [ String, Array ] - property :flush_cache, Hash, default: { before: false, after: false }, coerce: proc { |v| - # TODO these append rather than set. This is probably wrong behavior, but we're preserving it until we know - if v.is_a?(Array) - v.each { |arg| flush_cache[arg] = true } - flush_cache - elsif v.any? - v - else - # TODO calling flush_cache({}) does a get instead of a set. This is probably wrong behavior, but we're preserving it until we know - flush_cache - end - } + # the {} on the proc here is because rspec chokes if it's do...end + property :flush_cache, + Hash, + default: { before: false, after: false }, + coerce: proc { |v| + if v.is_a?(Array) + v.each_with_object({}) { |arg, obj| obj[arg] = true } + elsif v.any? + v + else + { before: v, after: v } + end + } property :allow_downgrade, [ true, false ], default: false property :yum_binary, String |