ruby - What is the correct way to check for the existence of a nested attribute in Chef? -


there multiple ways check existence of nested attribute in chef, , i'm not sure correct/best, , if result in empty attributes being stored on node:

node[:parent] , node[:parent][:child]  node.attribute?(:parent) , node[:parent].attribute?(:child))  node[:parent].nil? , node[:parent][:child].nil? 

it'd preferred able check parent , child @ same time, don't know if that's possible. using chef 10, not chef 11, though answers explaining either welcome.

node attribute object hashmap. can use ruby native api lookup nested attributes.

chef node object provides number of helper methods like:

node.attribute?() node[:foo].attribute?(:bar) node[:foo].member?(:bar) 

there new method node.debug_value() in chef 11 debug node attributes helpful:

node.debug_value(:foo, :bar) 

details can found article chef 11 in-depth: attributes changes


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -