Provides a simple interface to access hash paths.
The gem was written to help with specs, so use in production code will have an unknown performance hit.
Add this line to your application's Gemfile:
gem 'hash_path'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hash_path
Given the hash { 'foo' => { 'bar' => { 'baz' => 'hai' } } }
# Nil versions
my_hash.at_path("foo.bar.baz") #=> 'hai'
my_hash.at_path("foo.bar.barry") #=> nil
my_hash.at_path("not_a_key") #=> nil
# Or the raise version
my_hash.at_path!("foo.bar.baz") #=> 'hai'
my_hash.at_path!("foo.bar.barry") #=> raises
my_hash.at_path!("not_a_key") #=> raises
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request