Easily build nested hashes
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.autotest
.rspec
Gemfile
Gemfile.lock
README.md

README.md

I saw this post about recursively setting deep hash values and thought it would be more awesome if it didn't create a big empty hash tree when you check to see if a key is there.

So, with AutoHash, you can do this:

thing = AutoHash.new
thing['fingers']['count'] = 5

But you can also do this:

thing = AutoHash.new
if thing['fingers']
  puts "Thing has #{thing['fingers']['count']} fingers."
else
  puts "Thing's fingers are not yet defined."
end