superhash!

Superhash adds OpenStruct-like features to your hashes, but the magic goes as deep as you like:

@person = {
    :name => 'James',
    :age => 28,
    :male => true,
    :friends => {
        :chuck => {
            :age => 29,
            :location => 'USA'
        },
        :john_paul => {
            :age => 25,
            :location => 'France'
        }
    }
}

@person.name # => 'James'
@person.age  # => 28
@person.friends.chuck.age # => 29
@person.friends.john_paul.location # => 'France'

# You also get questioning methods:
@person.male? # => true

You get the idea :)

Installation

gem install superhash --source=http://gemcutter.org/

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Keep it simple!
  • 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 (c) 2010 James Wilding. See LICENSE for details.