Skip to content

Instantly share code, notes, and snippets.

@whatupdave
Created August 5, 2010 07:11
Show Gist options
  • Save whatupdave/509378 to your computer and use it in GitHub Desktop.
Save whatupdave/509378 to your computer and use it in GitHub Desktop.
class ROpenStruct < OpenStruct
def initialize(hash=nil)
@table = {}
for k,v in hash
@table[k.to_sym] = wrap(v)
new_ostruct_member(k)
end
end
def wrap(value)
case value
when Hash then ROpenStruct.new(value)
when Array then value.map{|item| wrap item }
else value
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment