class Options < Hash
def self.new(&a)
a = lambda{|h,k| h[k] = new(&a) } unless a
super(&a)
end
def method_missing(m, *a)
if m[-1] == "="
key = keys.find{|k| k.to_s == m[0...-1].to_s } || m[0...-1].to_sym
self[key] = a.first
else
key = keys.find{|k| k.to_s == m.to_s }
self[key]
end
end
end
h = Options.new
h[:a][:b][:c] = :foo
h[:d] = :bar
p h
p h.a
p h.a.b.c
h.e.f = :baz
p h.e
Y2xhc3MgT3B0aW9ucyA8IEhhc2gKICBkZWYgc2VsZi5uZXcoJmEpCiAgICBhID0gbGFtYmRhe3xoLGt8IGhba10gPSBuZXcoJmEpIH0gdW5sZXNzIGEKICAgIHN1cGVyKCZhKQogIGVuZAogIGRlZiBtZXRob2RfbWlzc2luZyhtLCAqYSkKICAgIGlmIG1bLTFdID09ICI9IgogICAgICBrZXkgPSBrZXlzLmZpbmR7fGt8IGsudG9fcyA9PSBtWzAuLi4tMV0udG9fcyB9IHx8IG1bMC4uLi0xXS50b19zeW0KICAgICAgc2VsZltrZXldID0gYS5maXJzdAogICAgZWxzZQogICAgICBrZXkgPSBrZXlzLmZpbmR7fGt8IGsudG9fcyA9PSBtLnRvX3MgfQogICAgICBzZWxmW2tleV0KICAgIGVuZAogIGVuZAplbmQKCmggPSBPcHRpb25zLm5ldwpoWzphXVs6Yl1bOmNdID0gOmZvbwpoWzpkXSA9IDpiYXIKCnAgaApwIGguYQpwIGguYS5iLmMKCmguZS5mID0gOmJhegpwIGguZQ==