Skip to content

Instantly share code, notes, and snippets.

@beccasaurus
Created April 22, 2010 03:10
Show Gist options
  • Save beccasaurus/374761 to your computer and use it in GitHub Desktop.
Save beccasaurus/374761 to your computer and use it in GitHub Desktop.
class Hash
def method_missing name, *args
if name.to_s =~ /=$/ # eg. @hash.foo = 'bar'
self[$`.to_s] = args.first
else
if args.empty?
self[name.to_s] # eg. @hash.foo
else
super # anything else ... fall back to super
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment