Skip to content

Instantly share code, notes, and snippets.

@brianstorti
Created November 15, 2011 01:06
Show Gist options
  • Save brianstorti/1365776 to your computer and use it in GitHub Desktop.
Save brianstorti/1365776 to your computer and use it in GitHub Desktop.
MyOpenScruct
class MyOpenStruct
def initialize
@attributes = {}
end
def method_missing(name, *args)
attribute = name.to_s
if attribute =~ /=$/
@attributes[attribute.chop] = args[0]
else
@attributes[attribute]
end
end
end
a = MyOpenStruct.new
a.name = "Brian"
puts a.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment