This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Chef::Node | |
# dig takes a node or databag and traverses through node/hash attributes according to the provided path | |
# databagitem.dig('this.attribute.here') | |
def dig(path, default=nil) | |
# works fine in chef 10 | |
path.split(".").inject(self) do |l,k| | |
if l.respond_to?(:keys) | |
(l.to_hash[k] || l.to_hash[k.to_sym] || default) | |
else | |
default |