# File lib/chef/node/attribute.rb, line 342 def set_value(data_hash, key, value) last = nil # If there is no current_nesting_level, just set the value if @current_nesting_level.length == 0 data_hash[key] = value return data_hash end # Walk all the previous places we have been 0.upto(@current_nesting_level.length) do |i| # If we are the first, we are top level, and should vivifiy the data_hash if i == 0 last = auto_vivifiy(data_hash, @current_nesting_level[i]) # If we are one past the last current_nesting_level, we are adding a key to that hash with a value elsif i == @current_nesting_level.length last[@current_nesting_level[i - 1]][key] = value # Otherwise, we're auto-vivifiy-ing an interim mash else last = auto_vivifiy(last[@current_nesting_level[i - 1]], @current_nesting_level[i]) end end data_hash end