@@ -81,8 +81,12 @@ PR please :)
8181
8282#### meta
8383
84- If you want a ` meta ` attribute in your response, specify it in the ` render `
85- call:
84+ A ` meta ` member can be used to include non-standard meta-information. ` meta ` can
85+ be utilized in several levels in a response.
86+
87+ ##### Top-level
88+
89+ To set top-level ` meta ` in a response, specify it in the ` render ` call.
8690
8791``` ruby
8892render json: @post , meta: { total: 10 }
@@ -94,12 +98,33 @@ The key can be customized using `meta_key` option.
9498render json: @post , meta: { total: 10 }, meta_key: " custom_meta"
9599```
96100
97- ` meta ` will only be included in your response if you are using an Adapter that supports ` root ` ,
98- as JsonAPI and Json adapters, the default adapter (Attributes) doesn't have ` root ` .
101+ ` meta ` will only be included in your response if you are using an Adapter that
102+ supports ` root ` , e.g., ` JsonApi ` and ` Json ` adapters. The default adapter,
103+ ` Attributes ` does not have ` root ` .
99104
100- #### meta_key
101105
102- PR please :)
106+ ##### Resource-level
107+
108+ To set resource-level ` meta ` in a response, define meta in a serializer with one
109+ of the following methods:
110+
111+ As a single, static string.
112+
113+ ``` ruby
114+ meta stuff: ' value'
115+ ```
116+
117+ As a block containing a Hash.
118+
119+ ``` ruby
120+ meta do
121+ {
122+ rating: 4 ,
123+ comments_count: object.comments.count
124+ }
125+ end
126+ ```
127+
103128
104129#### links
105130
0 commit comments