diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2021-01-15 13:01:02 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2021-01-15 13:01:02 -0800 |
commit | 3907a91627ba2850a17a0b4ad5401b0bc3a5d219 (patch) | |
tree | f6c2fe90842800bb8d3f6712e86106d1df4b72df | |
parent | 1f0e72db99e8d409ba90c7cd875ff4a51e5a1157 (diff) | |
download | chef-3907a91627ba2850a17a0b4ad5401b0bc3a5d219.tar.gz |
Do not change the behavior of plain-old-procs
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/delayed_evaluator.rb | 4 | ||||
-rw-r--r-- | lib/chef/node/immutable_collections.rb | 5 | ||||
-rw-r--r-- | lib/chef/node/mixin/deep_merge_cache.rb | 4 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/chef/delayed_evaluator.rb b/lib/chef/delayed_evaluator.rb index df734c8303..f200f88410 100644 --- a/lib/chef/delayed_evaluator.rb +++ b/lib/chef/delayed_evaluator.rb @@ -17,5 +17,9 @@ class Chef class DelayedEvaluator < Proc + def dup + # super returns a "Proc" (which seems buggy) so re-wrap it + self.class.new(&super) # rubocop:disable Layout/SpaceAroundKeyword + end end end diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 76816a2d59..79b1983a05 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -19,6 +19,7 @@ require_relative "common_api" require_relative "mixin/state_tracking" require_relative "mixin/immutablize_array" require_relative "mixin/immutablize_hash" +require_relative "../delayed_evaluator" class Chef class Node @@ -111,7 +112,7 @@ class Chef def [](*args) value = super - value = value.call while value.is_a?(Proc) + value = value.call while value.is_a?(::Chef::DelayedEvaluator) value end @@ -195,7 +196,7 @@ class Chef def [](*args) value = super - value = value.call while value.is_a?(Proc) + value = value.call while value.is_a?(::Chef::DelayedEvaluator) value end diff --git a/lib/chef/node/mixin/deep_merge_cache.rb b/lib/chef/node/mixin/deep_merge_cache.rb index c1c1d225d8..8978d77ea0 100644 --- a/lib/chef/node/mixin/deep_merge_cache.rb +++ b/lib/chef/node/mixin/deep_merge_cache.rb @@ -15,6 +15,8 @@ # limitations under the License. # +require_relative "../../delayed_evaluator" + class Chef class Node module Mixin @@ -53,7 +55,7 @@ class Chef # save all the work of computing node[key] deep_merge_cache[key.to_s] = merged_attributes(key) end - ret = ret.call while ret.is_a?(Proc) + ret = ret.call while ret.is_a?(::Chef::DelayedEvaluator) ret end |