Skip to content

Instantly share code, notes, and snippets.

@jaredatron
Created February 9, 2010 00:42
Show Gist options
  • Save jaredatron/298779 to your computer and use it in GitHub Desktop.
Save jaredatron/298779 to your computer and use it in GitHub Desktop.
require 'ostruct'
class NestedStruct < OpenStruct
def method_missing(name, *)
super(:"#{name}=", NestedStruct.new) unless name.to_s =~ /=$/
super
end
def marshal_dump
dump = super
dump.keys.each do |key|
dump[key] = dump[key].marshal_dump if dump[key].is_a?(self.class)
end
dump
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment