diff options
Diffstat (limited to 'lib/chef/property.rb')
-rw-r--r-- | lib/chef/property.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/chef/property.rb b/lib/chef/property.rb index c6f72e15a7..a72e41a61e 100644 --- a/lib/chef/property.rb +++ b/lib/chef/property.rb @@ -110,6 +110,20 @@ class Chef raise ArgumentError, "Cannot specify both default and name_property/name_attribute together on property #{self}" end + # Recursively freeze the default if it isn't a lazy value. + unless default.is_a?(DelayedEvaluator) + visitor = lambda do |obj| + case obj + when Hash + obj.each_value { |value| visitor.call(value) } + when Array + obj.each { |value| visitor.call(value) } + end + obj.freeze + end + visitor.call(default) + end + # Validate the default early, so the user gets a good error message, and # cache it so we don't do it again if so begin |