Support key transformation for Attributes adapter (#1889)

The `:attributes` adapter is the default one, but it did not support
key transformation. This was very surprising behavior, since the
"Configuration Options" page in the guides didn't mention that this
behavior was not supported by the attributes adapter.

This commit adds key transform support to the attributes adapter, and
adds documentation about the default transform for the attributes
adapter (which is `:unaltered`).

This commit also handles arrays when transforming keys, which was needed
in the case where you're serializing a collection with the Attributes
adapter. With the JSON adapter, it was always guaranteed to pass a hash
to the KeyTransform functions because of the top-level key. Since there
is no top-level key for the Attributes adapter, the return value could
be an array.
This commit is contained in:
Ian C. Anderson
2016-08-25 15:21:27 -04:00
committed by L. Preston Sego III
parent 49ee823a53
commit 2423ca4999
6 changed files with 84 additions and 1 deletions

View File

@@ -46,6 +46,7 @@ Each adapter has a default key transform configured:
| Adapter | Default Key Transform |
|----|----|
| `Attributes` | `:unaltered` |
| `Json` | `:unaltered` |
| `JsonApi` | `:dash` |