Skip to content

Instantly share code, notes, and snippets.

View tomduckering's full-sized avatar

Tom Duckering tomduckering

  • London
View GitHub Profile
@igor47
igor47 / chef_to_hash.rb
Created July 15, 2013 02:01
a recursive to_hash for chef 11; also handles arrays inside the hash.
class Chef
class Node
class ImmutableMash
def to_hash
h = {}
self.each do |k,v|
if v.respond_to?('to_hash')
h[k] = v.to_hash
elsif v.respond_to?('each')
h[k] = []