This gem adds Hash#dig and Array#dig from Ruby 2.3+ to earlier versions of Ruby. It is a no-op if you are running Ruby 2.3 or greater.
Add this line to your application's Gemfile:
gem 'ruby_dig'
And then execute:
$ bundle
Or install it yourself as:
$ gem install ruby_dig
require 'ruby_dig'
response = {mom: {first: "Marge", last: "Bouvier"},
dad: {first: "Homer", last: "Simpson"},
kids: [
{first: "Bart", last: "Simpson"},
{first: "Lisa", last: "Simpson"}
]}
response.dig(:kids, 1, :first)
# => "Lisa"
- Fork it ( https://github.com/Invoca/ruby_dig/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request