Recursively convert a Ruby hash to OpenStruct

Posted on June 20, 2012

I love OpenStruct. Like love love. The only reason I wouldn’t marry it is that it won’t recursively convert a nested hash to OpenStruct. So I wrote a hash extension to do just that. Wip out your credit cards, our wedding registry is forth coming.


Specs are here.

with_sym_keys method is here. Alternatively, you could replace that by converting HashWithIndifferentAccess if you are using Rails or want to include ActiveSupport.


No Replies to "Recursively convert a Ruby hash to OpenStruct"


    Got something to say?

    Some html is OK

    This site uses Akismet to reduce spam. Learn how your comment data is processed.