diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-15 12:05:43 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-15 12:05:43 -0700 |
commit | b37436b080ff3733736e70d1343d5f328ed840e4 (patch) | |
tree | e1de2ad7e6158d4406c591aae63b0bc9062ba6d8 /lib/chef/node | |
parent | 645054783c587301c3c1226581df5cfcd0a9b947 (diff) | |
download | chef-b37436b080ff3733736e70d1343d5f328ed840e4.tar.gz |
Chef-13 freeze merged node attributelcg/node-freeze
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/node')
-rw-r--r-- | lib/chef/node/immutable_collections.rb | 10 | ||||
-rw-r--r-- | lib/chef/node/mixin/immutablize_array.rb | 2 | ||||
-rw-r--r-- | lib/chef/node/mixin/immutablize_hash.rb | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/lib/chef/node/immutable_collections.rb b/lib/chef/node/immutable_collections.rb index 13a8aefe97..be9285a755 100644 --- a/lib/chef/node/immutable_collections.rb +++ b/lib/chef/node/immutable_collections.rb @@ -22,8 +22,14 @@ require "chef/node/mixin/immutablize_hash" class Chef class Node - module Immutablize + # For elements like Fixnums, true, nil... + def safe_dup(e) + e.dup + rescue TypeError + e + end + def immutablize(value) case value when Hash @@ -31,7 +37,7 @@ class Chef when Array ImmutableArray.new(value, __root__, __node__, __precedence__) else - value + safe_dup(value).freeze end end end diff --git a/lib/chef/node/mixin/immutablize_array.rb b/lib/chef/node/mixin/immutablize_array.rb index cfa7266b9a..bd330cf8a9 100644 --- a/lib/chef/node/mixin/immutablize_array.rb +++ b/lib/chef/node/mixin/immutablize_array.rb @@ -1,5 +1,5 @@ #-- -# Copyright:: Copyright 2016, Chef Software, Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/lib/chef/node/mixin/immutablize_hash.rb b/lib/chef/node/mixin/immutablize_hash.rb index f09e6944fc..f6b22ed7d7 100644 --- a/lib/chef/node/mixin/immutablize_hash.rb +++ b/lib/chef/node/mixin/immutablize_hash.rb @@ -1,5 +1,5 @@ #-- -# Copyright:: Copyright 2016, Chef Software, Inc. +# Copyright:: Copyright 2016-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); |