Nested OpenStruct alternative optimized for speed especially for many short-lived objects (e.g. results from db).
$ gem install hashugar
hashugar = {:a => 1, 'b' => {:c => 2, :d => [3, 4, {:e => 5}]}}.to_hashugar
hashugar.a # => 1
hashugar.b.c # => 2
hashugar.b.d.last.e # => 5
Ruby 1.9.3 benchmark
OpenStruct create small hash and access once
25546.3 (±5.9%) i/s - 128865 in 5.060934s (cycle=2343)
Hashugar create small hash and access once
570523.2 (±6.3%) i/s - 2857400 in 5.031212s (cycle=28574)
OpenStruct create big hash and access once
780.5 (±8.5%) i/s - 3927 in 5.066012s (cycle=77)
Hashugar create big hash and access once
779118.2 (±4.4%) i/s - 3911640 in 5.031364s (cycle=32597)
OpenStruct create small hash and access ten times
29389.7 (±10.6%) i/s - 146720 in 5.058931s (cycle=2620)
Hashugar create small hash and access ten times
105626.2 (±3.7%) i/s - 534421 in 5.066869s (cycle=8761)
OpenStruct create small hash and access fifty times
24329.8 (±4.2%) i/s - 123390 in 5.082089s (cycle=2285)
Hashugar create small hash and access fifty times
22246.2 (±2.9%) i/s - 112008 in 5.039232s (cycle=2154)
OpenStruct create small hash and access hundred times
20432.0 (±13.4%) i/s - 100912 in 5.011692s (cycle=1904)
Hashugar create small hash and access hundred times
11296.5 (±3.3%) i/s - 56940 in 5.046262s (cycle=1095)