Rename FlattenJson to Attributes (allow plural adapter names)

This commit is contained in:
Benjamin Fleischer
2015-09-04 04:22:10 -05:00
parent ceef214f1e
commit c6f8d0f5f2
15 changed files with 36 additions and 35 deletions

View File

@@ -3,11 +3,11 @@
AMS does this through two components: **serializers** and **adapters**.
Serializers describe _which_ attributes and relationships should be serialized.
Adapters describe _how_ attributes and relationships should be serialized.
You can use one of the built-in adapters (```FlattenJSON``` is the default one) or create one by yourself, but you won't need to implement an adapter unless you wish to use a new format or media type with AMS.
You can use one of the built-in adapters (```Attributes``` is the default one) or create one by yourself, but you won't need to implement an adapter unless you wish to use a new format or media type with AMS.
## Built in Adapters
### FlattenJSON - Default
### Attributes - Default
It's the default adapter, it generates a json response without a root key.
Doesn't follow any specifc convention.
@@ -51,7 +51,7 @@ ActiveModel::Serializer.config.adapter = :json_api
```
If you want to have a root key for each resource in your responses, you should use the Json or
JsonApi adapters instead of the default FlattenJson:
JsonApi adapters instead of the default Attributes:
```ruby
ActiveModel::Serializer.config.adapter = :json

View File

@@ -4,7 +4,7 @@ The following configuration options can be set on `ActiveModel::Serializer.confi
## General
- `adapter`: The [adapter](adapters.md) to use. Possible values: `:flatten_json, :json, :json_api`. Default: `:flatten_json`.
- `adapter`: The [adapter](adapters.md) to use. Possible values: `:attributes, :json, :json_api`. Default: `:attributes`.
## JSON API

View File

@@ -110,6 +110,6 @@ ex.
}
```
### FlattenJSON adapter
### Attributes adapter
This adapter does not allow us to use `meta` key, due to that it is not possible to add pagination links.

View File

@@ -1,6 +1,6 @@
# How to add root key
Add the root key to your API is quite simple with AMS. The **Adapter** is what determines the format of your JSON response. The default adapter is the ```FlattenJSON``` which doesn't have the root key, so your response is something similar to:
Add the root key to your API is quite simple with AMS. The **Adapter** is what determines the format of your JSON response. The default adapter is the ```Attributes``` which doesn't have the root key, so your response is something similar to:
```json
{