hash-to-ostruct recursively transforms Hash to OpenStruct
It supports:
-
hash of hashes
* hash of arrays with hashes as elements
# Example One: Hash of hashes require ‘hash-to-ostruct’
countries_hash = {} countries_hash = { :capital => ‘Canberra’, :currency_code => ‘AUD’ } countries_hash = { :capital => ‘London’, :currency_code => ‘GBP’ }
countries = countries_hash.to_ostruct
countries.australia.capital # returns “Canberra” countries.australia.currency_code # returns “AUD”
countries.england.capital # returns “London” countries.england.currency_code # returns “GBP”
sudo gem install hash-to-ostruct
Copyright © 2009 Kunal Parikh (kunal@techthumb.in)