Use #each_with_object instead of #inject.

Enumerable#inject requires the block to return the accumulator,
as #each_with_object stores the accumulator to be yielded internally.