Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

hashpipe is a hash with openstruct and coalesced symbol/string semantics.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
README.rdoc

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.

Examples:

h = HashPipe.new
h[:foo] = "bar"
h.foo             #=> "bar"
h["bar"] = "quux"
h[:bar]           #=> "quux"
h.bar             #=> "quux"

h.lock!   # no new attributes can be created

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

h.keys    #=> [:foo, :bar]
h.values  #=> ["bar", "quux"]

h.map { |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

Copyright © 2010 Erik Hollensbe. See LICENSE for details.

Something went wrong with that request. Please try again.