mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-24 14:56:50 +00:00
commit
c4902f778c
14
README.md
14
README.md
@ -1,13 +1,14 @@
|
|||||||
[](https://travis-ci.org/rails-api/active_model_serializers) [](https://codeclimate.com/github/rails-api/active_model_serializers) [](https://coveralls.io/r/rails-api/active_model_serializers)
|
[](https://travis-ci.org/rails-api/active_model_serializers)
|
||||||
|
[](https://codeclimate.com/github/rails-api/active_model_serializers)
|
||||||
|
[](https://coveralls.io/r/rails-api/active_model_serializers)
|
||||||
|
|
||||||
# ActiveModel::Serializers
|
# ActiveModel::Serializers
|
||||||
|
|
||||||
## Purpose
|
## Purpose
|
||||||
|
|
||||||
The purpose of `ActiveModel::Serializers` is to provide an object to
|
`ActiveModel::Serializers` encapsulates the JSON serialization of objects.
|
||||||
encapsulate serialization of objects which respond to
|
Objects that respond to read\_attribute\_for\_serialization
|
||||||
read\_attribute\_for\_serialization like ActiveModel ones and including
|
(including `ActiveModel` and `ActiveRecord` objects) are supported.
|
||||||
`ActiveRecord` objects.
|
|
||||||
|
|
||||||
Serializers know about both a model and the `current_user`, so you can
|
Serializers know about both a model and the `current_user`, so you can
|
||||||
customize serialization based upon whether a user is authorized to see the
|
customize serialization based upon whether a user is authorized to see the
|
||||||
@ -16,12 +17,11 @@ content.
|
|||||||
In short, **serializers replace hash-driven development with object-oriented
|
In short, **serializers replace hash-driven development with object-oriented
|
||||||
development.**
|
development.**
|
||||||
|
|
||||||
|
|
||||||
# Design and Implementation
|
# Design and Implementation
|
||||||
|
|
||||||
## Keep it Simple
|
## Keep it Simple
|
||||||
|
|
||||||
ActiveModel::Serializers is capable of producing complex JSON views/large object
|
`ActiveModel::Serializers` is capable of producing complex JSON views/large object
|
||||||
trees, and it may be tempting to design in this way so that your client can make
|
trees, and it may be tempting to design in this way so that your client can make
|
||||||
fewer requests to get data and so that related querying can be optimized.
|
fewer requests to get data and so that related querying can be optimized.
|
||||||
However, keeping things simple in your serializers and controllers may
|
However, keeping things simple in your serializers and controllers may
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user