jsonapi_compliable 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +11 -3
- data/.yardopts +1 -0
- data/README.md +10 -1
- data/Rakefile +1 -0
- data/docs/JsonapiCompliable.html +202 -0
- data/docs/JsonapiCompliable/Adapters.html +119 -0
- data/docs/JsonapiCompliable/Adapters/Abstract.html +2285 -0
- data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +2151 -0
- data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +582 -0
- data/docs/JsonapiCompliable/Adapters/Null.html +1682 -0
- data/docs/JsonapiCompliable/Base.html +1395 -0
- data/docs/JsonapiCompliable/Deserializer.html +835 -0
- data/docs/JsonapiCompliable/Errors.html +115 -0
- data/docs/JsonapiCompliable/Errors/BadFilter.html +124 -0
- data/docs/JsonapiCompliable/Errors/StatNotFound.html +266 -0
- data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +264 -0
- data/docs/JsonapiCompliable/Errors/ValidationError.html +124 -0
- data/docs/JsonapiCompliable/Extensions.html +117 -0
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +212 -0
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +229 -0
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +242 -0
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +237 -0
- data/docs/JsonapiCompliable/Query.html +1099 -0
- data/docs/JsonapiCompliable/Rails.html +211 -0
- data/docs/JsonapiCompliable/Resource.html +5241 -0
- data/docs/JsonapiCompliable/Scope.html +703 -0
- data/docs/JsonapiCompliable/Scoping.html +117 -0
- data/docs/JsonapiCompliable/Scoping/Base.html +843 -0
- data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +318 -0
- data/docs/JsonapiCompliable/Scoping/ExtraFields.html +301 -0
- data/docs/JsonapiCompliable/Scoping/Filter.html +313 -0
- data/docs/JsonapiCompliable/Scoping/Filterable.html +364 -0
- data/docs/JsonapiCompliable/Scoping/Paginate.html +613 -0
- data/docs/JsonapiCompliable/Scoping/Sort.html +454 -0
- data/docs/JsonapiCompliable/SerializableTempId.html +216 -0
- data/docs/JsonapiCompliable/Sideload.html +2484 -0
- data/docs/JsonapiCompliable/Stats.html +117 -0
- data/docs/JsonapiCompliable/Stats/DSL.html +999 -0
- data/docs/JsonapiCompliable/Stats/Payload.html +391 -0
- data/docs/JsonapiCompliable/Util.html +117 -0
- data/docs/JsonapiCompliable/Util/FieldParams.html +228 -0
- data/docs/JsonapiCompliable/Util/Hash.html +471 -0
- data/docs/JsonapiCompliable/Util/IncludeParams.html +299 -0
- data/docs/JsonapiCompliable/Util/Persistence.html +435 -0
- data/docs/JsonapiCompliable/Util/RelationshipPayload.html +563 -0
- data/docs/JsonapiCompliable/Util/RenderOptions.html +250 -0
- data/docs/JsonapiCompliable/Util/ValidationResponse.html +532 -0
- data/docs/_index.html +527 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +99 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +99 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1731 -0
- data/docs/top-level-namespace.html +110 -0
- data/gemfiles/rails_5.gemfile +1 -1
- data/lib/jsonapi_compliable/adapters/abstract.rb +267 -4
- data/lib/jsonapi_compliable/adapters/active_record.rb +23 -1
- data/lib/jsonapi_compliable/adapters/null.rb +43 -3
- data/lib/jsonapi_compliable/base.rb +182 -33
- data/lib/jsonapi_compliable/deserializer.rb +90 -21
- data/lib/jsonapi_compliable/extensions/boolean_attribute.rb +12 -0
- data/lib/jsonapi_compliable/extensions/extra_attribute.rb +32 -0
- data/lib/jsonapi_compliable/extensions/temp_id.rb +11 -0
- data/lib/jsonapi_compliable/query.rb +94 -2
- data/lib/jsonapi_compliable/rails.rb +8 -0
- data/lib/jsonapi_compliable/resource.rb +548 -11
- data/lib/jsonapi_compliable/scope.rb +43 -1
- data/lib/jsonapi_compliable/scoping/base.rb +59 -8
- data/lib/jsonapi_compliable/scoping/default_filter.rb +33 -0
- data/lib/jsonapi_compliable/scoping/extra_fields.rb +33 -0
- data/lib/jsonapi_compliable/scoping/filter.rb +29 -2
- data/lib/jsonapi_compliable/scoping/filterable.rb +4 -0
- data/lib/jsonapi_compliable/scoping/paginate.rb +33 -0
- data/lib/jsonapi_compliable/scoping/sort.rb +18 -0
- data/lib/jsonapi_compliable/sideload.rb +229 -1
- data/lib/jsonapi_compliable/stats/dsl.rb +44 -0
- data/lib/jsonapi_compliable/stats/payload.rb +20 -0
- data/lib/jsonapi_compliable/util/field_params.rb +1 -0
- data/lib/jsonapi_compliable/util/hash.rb +18 -0
- data/lib/jsonapi_compliable/util/include_params.rb +22 -0
- data/lib/jsonapi_compliable/util/persistence.rb +13 -3
- data/lib/jsonapi_compliable/util/relationship_payload.rb +2 -0
- data/lib/jsonapi_compliable/util/render_options.rb +2 -0
- data/lib/jsonapi_compliable/util/validation_response.rb +16 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +60 -5
- data/gemfiles/rails_4.gemfile.lock +0 -208
- data/gemfiles/rails_5.gemfile.lock +0 -212
- data/lib/jsonapi_compliable/write.rb +0 -93
@@ -0,0 +1,835 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: JsonapiCompliable::Deserializer
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "JsonapiCompliable::Deserializer";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (D)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Deserializer</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: JsonapiCompliable::Deserializer
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">JsonapiCompliable::Deserializer</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Defined in:</dt>
|
97
|
+
<dd>lib/jsonapi_compliable/deserializer.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>Responsible for parsing incoming write payloads</p>
|
106
|
+
|
107
|
+
<p>Given a PUT payload like:</p>
|
108
|
+
|
109
|
+
<pre class="code ruby"><code class="ruby">{
|
110
|
+
data: {
|
111
|
+
id: '1',
|
112
|
+
type: 'posts',
|
113
|
+
attributes: { title: 'My Title' },
|
114
|
+
relationships: {
|
115
|
+
author: {
|
116
|
+
data: {
|
117
|
+
id: '1',
|
118
|
+
type: 'authors'
|
119
|
+
}
|
120
|
+
}
|
121
|
+
}
|
122
|
+
},
|
123
|
+
included: [
|
124
|
+
{
|
125
|
+
id: '1'
|
126
|
+
type: 'authors',
|
127
|
+
attributes: { name: 'Joe Author' }
|
128
|
+
}
|
129
|
+
]
|
130
|
+
}</code></pre>
|
131
|
+
|
132
|
+
<p>You can now easily deal with this payload:</p>
|
133
|
+
|
134
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_deserializer'>deserializer</span><span class='period'>.</span><span class='id identifier rubyid_attributes'>attributes</span>
|
135
|
+
<span class='comment'># => { id: '1', title: 'My Title' }
|
136
|
+
</span><span class='id identifier rubyid_deserializer'>deserializer</span><span class='period'>.</span><span class='id identifier rubyid_meta'>meta</span>
|
137
|
+
<span class='comment'># => { type: 'posts', method: :update }
|
138
|
+
</span><span class='id identifier rubyid_deserializer'>deserializer</span><span class='period'>.</span><span class='id identifier rubyid_relationships'>relationships</span>
|
139
|
+
<span class='comment'># {
|
140
|
+
</span><span class='comment'># author: {
|
141
|
+
</span><span class='comment'># meta: { ... },
|
142
|
+
</span><span class='comment'># attributes: { ... },
|
143
|
+
</span><span class='comment'># relationships: { ... }
|
144
|
+
</span><span class='comment'># }
|
145
|
+
</span><span class='comment'># }
|
146
|
+
</span></code></pre>
|
147
|
+
|
148
|
+
<p>When creating objects, we accept a <code>temp-id</code> so that the client
|
149
|
+
can track the object it just created. Expect this in <code>meta</code>:</p>
|
150
|
+
|
151
|
+
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='label'>type:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>authors</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>method:</span> <span class='symbol'>:create</span><span class='comma'>,</span> <span class='label'>temp_id:</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>abc123</span><span class='tstring_end'>'</span></span> <span class='rbrace'>}</span>
|
152
|
+
</code></pre>
|
153
|
+
|
154
|
+
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
<div class="tags">
|
158
|
+
|
159
|
+
|
160
|
+
</div>
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
<h2>
|
169
|
+
Instance Method Summary
|
170
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
171
|
+
</h2>
|
172
|
+
|
173
|
+
<ul class="summary">
|
174
|
+
|
175
|
+
<li class="public ">
|
176
|
+
<span class="summary_signature">
|
177
|
+
|
178
|
+
<a href="#attributes-instance_method" title="#attributes (instance method)">#<strong>attributes</strong> ⇒ Hash </a>
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
</span>
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
<span class="summary_desc"><div class='inline'>
|
193
|
+
<p>The raw :attributes hash + <code>id</code>.</p>
|
194
|
+
</div></span>
|
195
|
+
|
196
|
+
</li>
|
197
|
+
|
198
|
+
|
199
|
+
<li class="public ">
|
200
|
+
<span class="summary_signature">
|
201
|
+
|
202
|
+
<a href="#data-instance_method" title="#data (instance method)">#<strong>data</strong> ⇒ Hash </a>
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
</span>
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
<span class="summary_desc"><div class='inline'>
|
217
|
+
<p>The raw :data value of the payload.</p>
|
218
|
+
</div></span>
|
219
|
+
|
220
|
+
</li>
|
221
|
+
|
222
|
+
|
223
|
+
<li class="public ">
|
224
|
+
<span class="summary_signature">
|
225
|
+
|
226
|
+
<a href="#id-instance_method" title="#id (instance method)">#<strong>id</strong> ⇒ String </a>
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
</span>
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
<span class="summary_desc"><div class='inline'>
|
241
|
+
<p>The raw :id value of the payload.</p>
|
242
|
+
</div></span>
|
243
|
+
|
244
|
+
</li>
|
245
|
+
|
246
|
+
|
247
|
+
<li class="public ">
|
248
|
+
<span class="summary_signature">
|
249
|
+
|
250
|
+
<a href="#include_directive-instance_method" title="#include_directive (instance method)">#<strong>include_directive</strong>(memo = {}, relationship_node = nil) ⇒ Hash </a>
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
</span>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
<span class="summary_desc"><div class='inline'>
|
265
|
+
<p>Parses the <code>relationships</code> recursively and builds an all-hash
|
266
|
+
include directive like.</p>
|
267
|
+
</div></span>
|
268
|
+
|
269
|
+
</li>
|
270
|
+
|
271
|
+
|
272
|
+
<li class="public ">
|
273
|
+
<span class="summary_signature">
|
274
|
+
|
275
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(payload, env) ⇒ Deserializer </a>
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
</span>
|
280
|
+
|
281
|
+
|
282
|
+
<span class="note title constructor">constructor</span>
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
<span class="summary_desc"><div class='inline'>
|
292
|
+
<p>A new instance of Deserializer.</p>
|
293
|
+
</div></span>
|
294
|
+
|
295
|
+
</li>
|
296
|
+
|
297
|
+
|
298
|
+
<li class="public ">
|
299
|
+
<span class="summary_signature">
|
300
|
+
|
301
|
+
<a href="#meta-instance_method" title="#meta (instance method)">#<strong>meta</strong> ⇒ Hash </a>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
</span>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<span class="summary_desc"><div class='inline'>
|
316
|
+
<p>'meta' information about this resource.</p>
|
317
|
+
</div></span>
|
318
|
+
|
319
|
+
</li>
|
320
|
+
|
321
|
+
|
322
|
+
<li class="public ">
|
323
|
+
<span class="summary_signature">
|
324
|
+
|
325
|
+
<a href="#relationships-instance_method" title="#relationships (instance method)">#<strong>relationships</strong> ⇒ Hash </a>
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
</span>
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
<span class="summary_desc"><div class='inline'>
|
340
|
+
<p>The relationships hash.</p>
|
341
|
+
</div></span>
|
342
|
+
|
343
|
+
</li>
|
344
|
+
|
345
|
+
|
346
|
+
</ul>
|
347
|
+
|
348
|
+
|
349
|
+
<div id="constructor_details" class="method_details_list">
|
350
|
+
<h2>Constructor Details</h2>
|
351
|
+
|
352
|
+
<div class="method_details first">
|
353
|
+
<h3 class="signature first" id="initialize-instance_method">
|
354
|
+
|
355
|
+
#<strong>initialize</strong>(payload, env) ⇒ <tt><span class='object_link'><a href="" title="JsonapiCompliable::Deserializer (class)">Deserializer</a></span></tt>
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
</h3><div class="docstring">
|
362
|
+
<div class="discussion">
|
363
|
+
|
364
|
+
<p>Returns a new instance of Deserializer</p>
|
365
|
+
|
366
|
+
|
367
|
+
</div>
|
368
|
+
</div>
|
369
|
+
<div class="tags">
|
370
|
+
<p class="tag_title">Parameters:</p>
|
371
|
+
<ul class="param">
|
372
|
+
|
373
|
+
<li>
|
374
|
+
|
375
|
+
<span class='name'>payload</span>
|
376
|
+
|
377
|
+
|
378
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
379
|
+
|
380
|
+
|
381
|
+
|
382
|
+
—
|
383
|
+
<div class='inline'>
|
384
|
+
<p>The incoming payload with symbolized keys</p>
|
385
|
+
</div>
|
386
|
+
|
387
|
+
</li>
|
388
|
+
|
389
|
+
<li>
|
390
|
+
|
391
|
+
<span class='name'>env</span>
|
392
|
+
|
393
|
+
|
394
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
395
|
+
|
396
|
+
|
397
|
+
|
398
|
+
—
|
399
|
+
<div class='inline'>
|
400
|
+
<p>the Rack env (e.g. <code>request.env</code>).</p>
|
401
|
+
</div>
|
402
|
+
|
403
|
+
</li>
|
404
|
+
|
405
|
+
</ul>
|
406
|
+
|
407
|
+
|
408
|
+
</div><table class="source_code">
|
409
|
+
<tr>
|
410
|
+
<td>
|
411
|
+
<pre class="lines">
|
412
|
+
|
413
|
+
|
414
|
+
50
|
415
|
+
51
|
416
|
+
52
|
417
|
+
53</pre>
|
418
|
+
</td>
|
419
|
+
<td>
|
420
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 50</span>
|
421
|
+
|
422
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_payload'>payload</span><span class='comma'>,</span> <span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
423
|
+
<span class='ivar'>@payload</span> <span class='op'>=</span> <span class='id identifier rubyid_payload'>payload</span>
|
424
|
+
<span class='ivar'>@env</span> <span class='op'>=</span> <span class='id identifier rubyid_env'>env</span>
|
425
|
+
<span class='kw'>end</span></pre>
|
426
|
+
</td>
|
427
|
+
</tr>
|
428
|
+
</table>
|
429
|
+
</div>
|
430
|
+
|
431
|
+
</div>
|
432
|
+
|
433
|
+
|
434
|
+
<div id="instance_method_details" class="method_details_list">
|
435
|
+
<h2>Instance Method Details</h2>
|
436
|
+
|
437
|
+
|
438
|
+
<div class="method_details first">
|
439
|
+
<h3 class="signature first" id="attributes-instance_method">
|
440
|
+
|
441
|
+
#<strong>attributes</strong> ⇒ <tt>Hash</tt>
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
</h3><div class="docstring">
|
448
|
+
<div class="discussion">
|
449
|
+
|
450
|
+
<p>Returns the raw :attributes hash + <code>id</code></p>
|
451
|
+
|
452
|
+
|
453
|
+
</div>
|
454
|
+
</div>
|
455
|
+
<div class="tags">
|
456
|
+
|
457
|
+
<p class="tag_title">Returns:</p>
|
458
|
+
<ul class="return">
|
459
|
+
|
460
|
+
<li>
|
461
|
+
|
462
|
+
|
463
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
—
|
468
|
+
<div class='inline'>
|
469
|
+
<p>the raw :attributes hash + <code>id</code></p>
|
470
|
+
</div>
|
471
|
+
|
472
|
+
</li>
|
473
|
+
|
474
|
+
</ul>
|
475
|
+
|
476
|
+
</div><table class="source_code">
|
477
|
+
<tr>
|
478
|
+
<td>
|
479
|
+
<pre class="lines">
|
480
|
+
|
481
|
+
|
482
|
+
66
|
483
|
+
67
|
484
|
+
68
|
485
|
+
69
|
486
|
+
70</pre>
|
487
|
+
</td>
|
488
|
+
<td>
|
489
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 66</span>
|
490
|
+
|
491
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_attributes'>attributes</span>
|
492
|
+
<span class='ivar'>@attributes</span> <span class='op'>||=</span> <span class='id identifier rubyid_raw_attributes'>raw_attributes</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
|
493
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='label'>id:</span> <span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_id'>id</span>
|
494
|
+
<span class='kw'>end</span>
|
495
|
+
<span class='kw'>end</span></pre>
|
496
|
+
</td>
|
497
|
+
</tr>
|
498
|
+
</table>
|
499
|
+
</div>
|
500
|
+
|
501
|
+
<div class="method_details ">
|
502
|
+
<h3 class="signature " id="data-instance_method">
|
503
|
+
|
504
|
+
#<strong>data</strong> ⇒ <tt>Hash</tt>
|
505
|
+
|
506
|
+
|
507
|
+
|
508
|
+
|
509
|
+
|
510
|
+
</h3><div class="docstring">
|
511
|
+
<div class="discussion">
|
512
|
+
|
513
|
+
<p>Returns the raw :data value of the payload</p>
|
514
|
+
|
515
|
+
|
516
|
+
</div>
|
517
|
+
</div>
|
518
|
+
<div class="tags">
|
519
|
+
|
520
|
+
<p class="tag_title">Returns:</p>
|
521
|
+
<ul class="return">
|
522
|
+
|
523
|
+
<li>
|
524
|
+
|
525
|
+
|
526
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
527
|
+
|
528
|
+
|
529
|
+
|
530
|
+
—
|
531
|
+
<div class='inline'>
|
532
|
+
<p>the raw :data value of the payload</p>
|
533
|
+
</div>
|
534
|
+
|
535
|
+
</li>
|
536
|
+
|
537
|
+
</ul>
|
538
|
+
|
539
|
+
</div><table class="source_code">
|
540
|
+
<tr>
|
541
|
+
<td>
|
542
|
+
<pre class="lines">
|
543
|
+
|
544
|
+
|
545
|
+
56
|
546
|
+
57
|
547
|
+
58</pre>
|
548
|
+
</td>
|
549
|
+
<td>
|
550
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 56</span>
|
551
|
+
|
552
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_data'>data</span>
|
553
|
+
<span class='ivar'>@payload</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span>
|
554
|
+
<span class='kw'>end</span></pre>
|
555
|
+
</td>
|
556
|
+
</tr>
|
557
|
+
</table>
|
558
|
+
</div>
|
559
|
+
|
560
|
+
<div class="method_details ">
|
561
|
+
<h3 class="signature " id="id-instance_method">
|
562
|
+
|
563
|
+
#<strong>id</strong> ⇒ <tt>String</tt>
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
</h3><div class="docstring">
|
570
|
+
<div class="discussion">
|
571
|
+
|
572
|
+
<p>Returns the raw :id value of the payload</p>
|
573
|
+
|
574
|
+
|
575
|
+
</div>
|
576
|
+
</div>
|
577
|
+
<div class="tags">
|
578
|
+
|
579
|
+
<p class="tag_title">Returns:</p>
|
580
|
+
<ul class="return">
|
581
|
+
|
582
|
+
<li>
|
583
|
+
|
584
|
+
|
585
|
+
<span class='type'>(<tt>String</tt>)</span>
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
—
|
590
|
+
<div class='inline'>
|
591
|
+
<p>the raw :id value of the payload</p>
|
592
|
+
</div>
|
593
|
+
|
594
|
+
</li>
|
595
|
+
|
596
|
+
</ul>
|
597
|
+
|
598
|
+
</div><table class="source_code">
|
599
|
+
<tr>
|
600
|
+
<td>
|
601
|
+
<pre class="lines">
|
602
|
+
|
603
|
+
|
604
|
+
61
|
605
|
+
62
|
606
|
+
63</pre>
|
607
|
+
</td>
|
608
|
+
<td>
|
609
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 61</span>
|
610
|
+
|
611
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_id'>id</span>
|
612
|
+
<span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span>
|
613
|
+
<span class='kw'>end</span></pre>
|
614
|
+
</td>
|
615
|
+
</tr>
|
616
|
+
</table>
|
617
|
+
</div>
|
618
|
+
|
619
|
+
<div class="method_details ">
|
620
|
+
<h3 class="signature " id="include_directive-instance_method">
|
621
|
+
|
622
|
+
#<strong>include_directive</strong>(memo = {}, relationship_node = nil) ⇒ <tt>Hash</tt>
|
623
|
+
|
624
|
+
|
625
|
+
|
626
|
+
|
627
|
+
|
628
|
+
</h3><div class="docstring">
|
629
|
+
<div class="discussion">
|
630
|
+
|
631
|
+
<p>Parses the <code>relationships</code> recursively and builds an all-hash
|
632
|
+
include directive like</p>
|
633
|
+
|
634
|
+
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='label'>posts:</span> <span class='lbrace'>{</span> <span class='label'>comments:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
635
|
+
</code></pre>
|
636
|
+
|
637
|
+
<p>Relationships that have been marked for destruction will NOT be part of the
|
638
|
+
include directive.</p>
|
639
|
+
|
640
|
+
|
641
|
+
</div>
|
642
|
+
</div>
|
643
|
+
<div class="tags">
|
644
|
+
|
645
|
+
<p class="tag_title">Returns:</p>
|
646
|
+
<ul class="return">
|
647
|
+
|
648
|
+
<li>
|
649
|
+
|
650
|
+
|
651
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
—
|
656
|
+
<div class='inline'>
|
657
|
+
<p>the include directive</p>
|
658
|
+
</div>
|
659
|
+
|
660
|
+
</li>
|
661
|
+
|
662
|
+
</ul>
|
663
|
+
|
664
|
+
</div><table class="source_code">
|
665
|
+
<tr>
|
666
|
+
<td>
|
667
|
+
<pre class="lines">
|
668
|
+
|
669
|
+
|
670
|
+
101
|
671
|
+
102
|
672
|
+
103
|
673
|
+
104
|
674
|
+
105
|
675
|
+
106
|
676
|
+
107
|
677
|
+
108
|
678
|
+
109</pre>
|
679
|
+
</td>
|
680
|
+
<td>
|
681
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 101</span>
|
682
|
+
|
683
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_include_directive'>include_directive</span><span class='lparen'>(</span><span class='id identifier rubyid_memo'>memo</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_relationship_node'>relationship_node</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
|
684
|
+
<span class='id identifier rubyid_relationship_node'>relationship_node</span> <span class='op'>||=</span> <span class='id identifier rubyid_relationships'>relationships</span>
|
685
|
+
|
686
|
+
<span class='id identifier rubyid_relationship_node'>relationship_node</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_relationship_payload'>relationship_payload</span><span class='op'>|</span>
|
687
|
+
<span class='id identifier rubyid_merge_include_directive'>merge_include_directive</span><span class='lparen'>(</span><span class='id identifier rubyid_memo'>memo</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_relationship_payload'>relationship_payload</span><span class='rparen'>)</span>
|
688
|
+
<span class='kw'>end</span>
|
689
|
+
|
690
|
+
<span class='id identifier rubyid_memo'>memo</span>
|
691
|
+
<span class='kw'>end</span></pre>
|
692
|
+
</td>
|
693
|
+
</tr>
|
694
|
+
</table>
|
695
|
+
</div>
|
696
|
+
|
697
|
+
<div class="method_details ">
|
698
|
+
<h3 class="signature " id="meta-instance_method">
|
699
|
+
|
700
|
+
#<strong>meta</strong> ⇒ <tt>Hash</tt>
|
701
|
+
|
702
|
+
|
703
|
+
|
704
|
+
|
705
|
+
|
706
|
+
</h3><div class="docstring">
|
707
|
+
<div class="discussion">
|
708
|
+
|
709
|
+
<p>'meta' information about this resource. Includes:</p>
|
710
|
+
|
711
|
+
<p><code>type</code>: the jsonapi type <code>method</code>:
|
712
|
+
create/update/destroy/disassociate. Based on the request env or the
|
713
|
+
<code>method</code> within the <code>relationships</code> hash
|
714
|
+
<code>temp_id</code>: the <code>temp-id</code>, if specified</p>
|
715
|
+
|
716
|
+
|
717
|
+
</div>
|
718
|
+
</div>
|
719
|
+
<div class="tags">
|
720
|
+
|
721
|
+
<p class="tag_title">Returns:</p>
|
722
|
+
<ul class="return">
|
723
|
+
|
724
|
+
<li>
|
725
|
+
|
726
|
+
|
727
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
728
|
+
|
729
|
+
|
730
|
+
|
731
|
+
</li>
|
732
|
+
|
733
|
+
</ul>
|
734
|
+
|
735
|
+
</div><table class="source_code">
|
736
|
+
<tr>
|
737
|
+
<td>
|
738
|
+
<pre class="lines">
|
739
|
+
|
740
|
+
|
741
|
+
79
|
742
|
+
80
|
743
|
+
81
|
744
|
+
82
|
745
|
+
83
|
746
|
+
84
|
747
|
+
85</pre>
|
748
|
+
</td>
|
749
|
+
<td>
|
750
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 79</span>
|
751
|
+
|
752
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_meta'>meta</span>
|
753
|
+
<span class='lbrace'>{</span>
|
754
|
+
<span class='label'>type:</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:type</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
755
|
+
<span class='label'>temp_id:</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='symbol'>:temp-id</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
|
756
|
+
<span class='label'>method:</span> <span class='id identifier rubyid_method'>method</span>
|
757
|
+
<span class='rbrace'>}</span>
|
758
|
+
<span class='kw'>end</span></pre>
|
759
|
+
</td>
|
760
|
+
</tr>
|
761
|
+
</table>
|
762
|
+
</div>
|
763
|
+
|
764
|
+
<div class="method_details ">
|
765
|
+
<h3 class="signature " id="relationships-instance_method">
|
766
|
+
|
767
|
+
#<strong>relationships</strong> ⇒ <tt>Hash</tt>
|
768
|
+
|
769
|
+
|
770
|
+
|
771
|
+
|
772
|
+
|
773
|
+
</h3><div class="docstring">
|
774
|
+
<div class="discussion">
|
775
|
+
|
776
|
+
<p>Returns the relationships hash</p>
|
777
|
+
|
778
|
+
|
779
|
+
</div>
|
780
|
+
</div>
|
781
|
+
<div class="tags">
|
782
|
+
|
783
|
+
<p class="tag_title">Returns:</p>
|
784
|
+
<ul class="return">
|
785
|
+
|
786
|
+
<li>
|
787
|
+
|
788
|
+
|
789
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
790
|
+
|
791
|
+
|
792
|
+
|
793
|
+
—
|
794
|
+
<div class='inline'>
|
795
|
+
<p>the relationships hash</p>
|
796
|
+
</div>
|
797
|
+
|
798
|
+
</li>
|
799
|
+
|
800
|
+
</ul>
|
801
|
+
|
802
|
+
</div><table class="source_code">
|
803
|
+
<tr>
|
804
|
+
<td>
|
805
|
+
<pre class="lines">
|
806
|
+
|
807
|
+
|
808
|
+
88
|
809
|
+
89
|
810
|
+
90</pre>
|
811
|
+
</td>
|
812
|
+
<td>
|
813
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/deserializer.rb', line 88</span>
|
814
|
+
|
815
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_relationships'>relationships</span>
|
816
|
+
<span class='ivar'>@relationships</span> <span class='op'>||=</span> <span class='id identifier rubyid_process_relationships'>process_relationships</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_relationships'>raw_relationships</span><span class='rparen'>)</span>
|
817
|
+
<span class='kw'>end</span></pre>
|
818
|
+
</td>
|
819
|
+
</tr>
|
820
|
+
</table>
|
821
|
+
</div>
|
822
|
+
|
823
|
+
</div>
|
824
|
+
|
825
|
+
</div>
|
826
|
+
|
827
|
+
<div id="footer">
|
828
|
+
Generated on Fri May 5 15:53:22 2017 by
|
829
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
830
|
+
0.9.9 (ruby-2.3.0).
|
831
|
+
</div>
|
832
|
+
|
833
|
+
</div>
|
834
|
+
</body>
|
835
|
+
</html>
|