class Hashery::QueryHash

QueryHash is essentially a Hash class, but with some OpenStruct-like features.

q = QueryHash.new

Entries can be added to the Hash via a setter method.

q.a = 1

Then looked up via a query method.

q.a?  #=> 1

The can also be looked up via a bang method.

q.a!  #=> 1

The difference between query methods and bang methods is that the bang method will auto-instantiate the entry if not present, where as a query method will not.

A QueryHash might not be quite as elegant as an OpenHash in that reader methods must end in ‘?` or `!`, but it remains fully compatible with Hash regardless of it’s settings.