Turn deeply nested hashes and arrays (like an API response) into a whiney object with method syntax.
Fetching(HTTParty.get(url, query: query)).forms[0].request_form_id
# fails loudly unless the response from HTTParty has a top level `forms` key
# fails loudly if `forms` is an empty array
# fails loudly if the first `form` doesn't have a `request_form_id` keyOr, if you prefer to learn from slide decks -- As presented at RailsConf 2014
Add this line to your application's Gemfile:
gem 'fetching'
And then execute:
$ bundle
- Fork it
- 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 new Pull Request