Yesterday I ported some existing code to a different gem. Instead of returning objects, the new gem returns hashes. To stave off a major refactor, I casted each hash to an OpenStruct which allows you get hash values with dot notation.

house = {}
house["bedrooms"] = 5
house = OpenStruct.new house
house.bedrooms #=> 5

Comments