Replace use of `#each_with_object` to support Ruby 1.8