Method: Chef::Node::CommonAPI#write!
- Defined in:
- lib/chef/node/common_api.rb
#write!(*args, &block) ⇒ Object
this autovivifies, but can throw NoSuchAttribute when trying to access #[] on something that is not a container ("schema violation" issues).
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/chef/node/common_api.rb', line 57 def write!(*args, &block) value = block_given? ? yield : args.pop last = args.pop obj = args.inject(self) do |memo, key| raise Chef::Exceptions::AttributeTypeMismatch unless valid_container?(memo, key) memo[key] end raise Chef::Exceptions::AttributeTypeMismatch unless valid_container?(obj, last) obj[last] = value end |