Skip to content

Instantly share code, notes, and snippets.

@jdblack
Created February 27, 2017 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jdblack/1eed5d3a5c2d155159447ce5362a462f to your computer and use it in GitHub Desktop.
Save jdblack/1eed5d3a5c2d155159447ce5362a462f to your computer and use it in GitHub Desktop.
module Dig
def dig(path,default=nil)
puts "Entering dig"
path.split(".").inject(self) do |l,k|
l.respond_to?(:keys) ? (l.to_hash[k] || l.to_hash[k.to_sym] || default):default
end
end
end
class Chef::Node
include Dig
end
class Chef::DataBagItem
include Dig
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment