Converting attributes to ruby hash


#1

Hi!

I’ve been wrestling with this issue ever since we got auto-upgraded to Chef 11,
and I can’t find a good solution. How do I recursively convert an attribute
into an ordinary ruby hash? I’ve posted a better description of the problem on
stack overflow:

I would love any pointers here!

Thanks,
–Igor


#2

Igor,
From your stackoverflow question I would say you are having issues because you are accessing the attributes using dot notation. Try:

config = node[‘myapp’][‘config’].to_hash
JSON.parse(config.to_json)


Seth Chisamore
Software Development Engineer, Opscode, Inc.
IRC, Skype, Twitter, Github: schisamo

On Feb 6, 2013, at 3:54 PM, igor.serebryany@airbnb.com
wrote:

Hi!

I’ve been wrestling with this issue ever since we got auto-upgraded to Chef 11,
and I can’t find a good solution. How do I recursively convert an attribute
into an ordinary ruby hash? I’ve posted a better description of the problem on
stack overflow:

http://stackoverflow.com/questions/14738364/chef-11-any-way-to-turn-attributes-into-a-ruby-hash

I would love any pointers here!

Thanks,
–Igor

[0] https://github.com/opscode/chef/blob/master/lib/chef/node.rb#L356-L368