Whoa just saw this awesome bit of code in Tire a Ruby gem for Elasticsearch:

@total = response['hits']['total'].to_i rescue nil

For so long I have been checking Ruby Hash's like that with a nil? or exists? check after every one.

Never again!