Skip to content
hashpipe is a hash with openstruct and coalesced symbol/string semantics.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


HashPipe – hash-alike openstructs for ruby.

Come on and kick me.
You’ve got your problems;
I’ve got my ass wide
You’ve got your big G's;
I’ve got my hash pipe.

- Weezer, /Hash Pipe/

HashPipe is a library to supplement users of OpenStruct and similar libs. It operates leak free at insertion cost and optimizes for the common case: reading, like a good hash table should. HashPipe includes Enumerable and a basic keys/values implementation.

HashPipe also contains a locking mechanism whereby you can eliminate the ability to add more items, similar to Object#freeze in a sense.


h =
h[:foo] = "bar"             #=> "bar"
h["bar"] = "quux"
h[:bar]           #=> "quux"             #=> "quux"

h.lock!   # no new attributes can be created

h.quux    # raises
h[:quux]  # raises
h['quux'] # raises     #=> "bar"

h.keys    #=> [:foo, :bar]
h.values  #=> ["bar", "quux"] { |k,v| [k,v] } #=> [[:foo, "bar"], [:bar, "quux"]]

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.


Copyright © 2010 Erik Hollensbe. See LICENSE for details.

Something went wrong with that request. Please try again.