Allow attributes with non-String keys

This allows keys of attributes to be object that don’t respond to `to_sym`.

It also improves the implementation by reducing the number of intermediate objects created (hashes and arrays). Using `#inject` was not such a good idea. :)

This is similar to PR #304.