Skip to content

Commit 9752c55

Browse files
committed
Add subsections to defining serializable resources guide.
1 parent aba9027 commit 9752c55

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

source/guides/serialization/defining.html.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ Relationships are declared via the `has_many`, `has_one` and `belongs_to` DSL
153153
methods. `belongs_to` is actually an alias for `has_one`, and you can use both
154154
interchangeably.
155155

156+
### Basics
157+
156158
The shortest way to declare an association is simply:
157159

158160
```ruby
@@ -181,6 +183,8 @@ class SerializablePost < JSONAPI::Serializable::Resource
181183
end
182184
```
183185

186+
### Relationship-level links and meta
187+
184188
Moreover, it is possible to declare links and meta informations inside a
185189
relationship via the `meta` and `link` DSL methods, the same way as for
186190
resource-level links and meta information.
@@ -199,6 +203,8 @@ class SerializablePost < JSONAPI::Serializable::Resource
199203
end
200204
```
201205

206+
### Serializable resource class inference
207+
202208
By default, for an instance of class `Post`, the corresponding serializable
203209
resource class will be assumed to be `SerializablePost` (this behavior can be
204210
configured, see next section).
@@ -231,7 +237,8 @@ class SerializablePost < JSONAPI::Serializable::Resource
231237
end
232238
```
233239

240+
### Linkage data overriding
241+
234242
Note: it is also possible to manually override the linkage data for a
235243
relationship (which can be useful to add linkage-level meta information) via the
236244
`linkage` DSL method.
237-

0 commit comments

Comments
 (0)