diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-04 12:24:07 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-04 12:24:07 +0200 |
commit | f15cb040becf52f8e2cb93f21fb2956e53ff75a6 (patch) | |
tree | 684257ba894e0795287fca532f3e10f3ce7ae5b7 | |
parent | f53681b3f8b2eecc43269f8995f53b6f03a9723e (diff) | |
download | gitlab-ce-docs/gb/document-serializers.tar.gz |
Copyedit documentation about using serializersdocs/gb/document-serializers
-rw-r--r-- | app/serializers/README.md | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/serializers/README.md b/app/serializers/README.md index d870d08d70b..26d27d37fe4 100644 --- a/app/serializers/README.md +++ b/app/serializers/README.md @@ -5,15 +5,15 @@ This is a documentation for classes located in `app/serializers` directory. In GitLab, we use [grape-entities][grape-entity-project], accompanied by a serializer, to convert a Ruby object to its JSON representation. -Serializers are typically used in a controllers to build a JSON response +Serializers are typically used in controllers to build a JSON response that is usually consumed by a frontend code. ## What is a serializer? -Serializer is a class that encapsulates all business rules for building a JSON -response using serialization entities. +A serializer is a class that encapsulates all business rules for building a +JSON response using serialization entities. -## What are serialization entities? +## What is a serialization entity? Entities are a lightweight structures that allow to represent domain models in a consistent and abstracted way, and reuse them as a building blocks to @@ -22,7 +22,7 @@ create a payload. Entities located in `app/serializers` are usually derived from a [`Grape::Entity`][grape-entity] class. -Serialization entities that do require a to have a knowledge about specific +Serialization entities that do require to have a knowledge about specific elements of the request, need to mix `RequestAwareEntity` in. ## How to implement a serializer? @@ -34,5 +34,8 @@ class in `app/serializers`. See existing serializers for an example. ## How to use serializer in a controller? +## Best practices + [grape-entity-project]: https://github.com/ruby-grape/grape-entity [grape-entity-class]: https://github.com/ruby-grape/grape-entity/blob/master/lib/grape_entity/entity.rb + |