Skip to content

Instantly share code, notes, and snippets.

View zeppelin's full-sized avatar
🐹

Gabor Babicz zeppelin

🐹
View GitHub Profile
@zeppelin
zeppelin / hashes2ostruct.rb
Created November 29, 2010 11:21
Ruby Hash to OpenStruct converter function
# Found at http://www.dribin.org/dave/blog/archives/2006/11/17/hashes_to_ostruct/
require 'ostruct'
def hashes2ostruct(object)
return case object
when Hash
object = object.clone
object.each do |key, value|
object[key] = hashes2ostruct(value)