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.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/.travis.yml +11 -3
  4. data/.yardopts +1 -0
  5. data/README.md +10 -1
  6. data/Rakefile +1 -0
  7. data/docs/JsonapiCompliable.html +202 -0
  8. data/docs/JsonapiCompliable/Adapters.html +119 -0
  9. data/docs/JsonapiCompliable/Adapters/Abstract.html +2285 -0
  10. data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +2151 -0
  11. data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +582 -0
  12. data/docs/JsonapiCompliable/Adapters/Null.html +1682 -0
  13. data/docs/JsonapiCompliable/Base.html +1395 -0
  14. data/docs/JsonapiCompliable/Deserializer.html +835 -0
  15. data/docs/JsonapiCompliable/Errors.html +115 -0
  16. data/docs/JsonapiCompliable/Errors/BadFilter.html +124 -0
  17. data/docs/JsonapiCompliable/Errors/StatNotFound.html +266 -0
  18. data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +264 -0
  19. data/docs/JsonapiCompliable/Errors/ValidationError.html +124 -0
  20. data/docs/JsonapiCompliable/Extensions.html +117 -0
  21. data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +212 -0
  22. data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +229 -0
  23. data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +242 -0
  24. data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +237 -0
  25. data/docs/JsonapiCompliable/Query.html +1099 -0
  26. data/docs/JsonapiCompliable/Rails.html +211 -0
  27. data/docs/JsonapiCompliable/Resource.html +5241 -0
  28. data/docs/JsonapiCompliable/Scope.html +703 -0
  29. data/docs/JsonapiCompliable/Scoping.html +117 -0
  30. data/docs/JsonapiCompliable/Scoping/Base.html +843 -0
  31. data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +318 -0
  32. data/docs/JsonapiCompliable/Scoping/ExtraFields.html +301 -0
  33. data/docs/JsonapiCompliable/Scoping/Filter.html +313 -0
  34. data/docs/JsonapiCompliable/Scoping/Filterable.html +364 -0
  35. data/docs/JsonapiCompliable/Scoping/Paginate.html +613 -0
  36. data/docs/JsonapiCompliable/Scoping/Sort.html +454 -0
  37. data/docs/JsonapiCompliable/SerializableTempId.html +216 -0
  38. data/docs/JsonapiCompliable/Sideload.html +2484 -0
  39. data/docs/JsonapiCompliable/Stats.html +117 -0
  40. data/docs/JsonapiCompliable/Stats/DSL.html +999 -0
  41. data/docs/JsonapiCompliable/Stats/Payload.html +391 -0
  42. data/docs/JsonapiCompliable/Util.html +117 -0
  43. data/docs/JsonapiCompliable/Util/FieldParams.html +228 -0
  44. data/docs/JsonapiCompliable/Util/Hash.html +471 -0
  45. data/docs/JsonapiCompliable/Util/IncludeParams.html +299 -0
  46. data/docs/JsonapiCompliable/Util/Persistence.html +435 -0
  47. data/docs/JsonapiCompliable/Util/RelationshipPayload.html +563 -0
  48. data/docs/JsonapiCompliable/Util/RenderOptions.html +250 -0
  49. data/docs/JsonapiCompliable/Util/ValidationResponse.html +532 -0
  50. data/docs/_index.html +527 -0
  51. data/docs/class_list.html +51 -0
  52. data/docs/css/common.css +1 -0
  53. data/docs/css/full_list.css +58 -0
  54. data/docs/css/style.css +492 -0
  55. data/docs/file.README.html +99 -0
  56. data/docs/file_list.html +56 -0
  57. data/docs/frames.html +17 -0
  58. data/docs/index.html +99 -0
  59. data/docs/js/app.js +248 -0
  60. data/docs/js/full_list.js +216 -0
  61. data/docs/js/jquery.js +4 -0
  62. data/docs/method_list.html +1731 -0
  63. data/docs/top-level-namespace.html +110 -0
  64. data/gemfiles/rails_5.gemfile +1 -1
  65. data/lib/jsonapi_compliable/adapters/abstract.rb +267 -4
  66. data/lib/jsonapi_compliable/adapters/active_record.rb +23 -1
  67. data/lib/jsonapi_compliable/adapters/null.rb +43 -3
  68. data/lib/jsonapi_compliable/base.rb +182 -33
  69. data/lib/jsonapi_compliable/deserializer.rb +90 -21
  70. data/lib/jsonapi_compliable/extensions/boolean_attribute.rb +12 -0
  71. data/lib/jsonapi_compliable/extensions/extra_attribute.rb +32 -0
  72. data/lib/jsonapi_compliable/extensions/temp_id.rb +11 -0
  73. data/lib/jsonapi_compliable/query.rb +94 -2
  74. data/lib/jsonapi_compliable/rails.rb +8 -0
  75. data/lib/jsonapi_compliable/resource.rb +548 -11
  76. data/lib/jsonapi_compliable/scope.rb +43 -1
  77. data/lib/jsonapi_compliable/scoping/base.rb +59 -8
  78. data/lib/jsonapi_compliable/scoping/default_filter.rb +33 -0
  79. data/lib/jsonapi_compliable/scoping/extra_fields.rb +33 -0
  80. data/lib/jsonapi_compliable/scoping/filter.rb +29 -2
  81. data/lib/jsonapi_compliable/scoping/filterable.rb +4 -0
  82. data/lib/jsonapi_compliable/scoping/paginate.rb +33 -0
  83. data/lib/jsonapi_compliable/scoping/sort.rb +18 -0
  84. data/lib/jsonapi_compliable/sideload.rb +229 -1
  85. data/lib/jsonapi_compliable/stats/dsl.rb +44 -0
  86. data/lib/jsonapi_compliable/stats/payload.rb +20 -0
  87. data/lib/jsonapi_compliable/util/field_params.rb +1 -0
  88. data/lib/jsonapi_compliable/util/hash.rb +18 -0
  89. data/lib/jsonapi_compliable/util/include_params.rb +22 -0
  90. data/lib/jsonapi_compliable/util/persistence.rb +13 -3
  91. data/lib/jsonapi_compliable/util/relationship_payload.rb +2 -0
  92. data/lib/jsonapi_compliable/util/render_options.rb +2 -0
  93. data/lib/jsonapi_compliable/util/validation_response.rb +16 -0
  94. data/lib/jsonapi_compliable/version.rb +1 -1
  95. metadata +60 -5
  96. data/gemfiles/rails_4.gemfile.lock +0 -208
  97. data/gemfiles/rails_5.gemfile.lock +0 -212
  98. data/lib/jsonapi_compliable/write.rb +0 -93
@@ -0,0 +1,1395 @@
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
+ Module: JsonapiCompliable::Base
8
+
9
+ &mdash; 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::Base";
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 (B)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span>
41
+ &raquo;
42
+ <span class="title">Base</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>Module: JsonapiCompliable::Base
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+ <dl>
73
+ <dt>Extended by:</dt>
74
+ <dd>ActiveSupport::Concern</dd>
75
+ </dl>
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+ <dl>
85
+ <dt>Defined in:</dt>
86
+ <dd>lib/jsonapi_compliable/base.rb</dd>
87
+ </dl>
88
+
89
+ </div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+
94
+ <p>Provides main interface to jsonapi_compliable</p>
95
+
96
+ <p>This gets mixed in to a “context” class, such as a Rails controller.</p>
97
+
98
+
99
+ </div>
100
+ </div>
101
+ <div class="tags">
102
+
103
+
104
+ </div>
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+ <h2>
113
+ Class Method Summary
114
+ <small><a href="#" class="summary_toggle">collapse</a></small>
115
+ </h2>
116
+
117
+ <ul class="summary">
118
+
119
+ <li class="public ">
120
+ <span class="summary_signature">
121
+
122
+ <a href="#jsonapi-class_method" title="jsonapi (class method)">.<strong>jsonapi</strong>(foo = &#39;bar&#39;, resource: nil, &amp;blk) &#x21d2; void </a>
123
+
124
+
125
+
126
+ </span>
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+ <span class="summary_desc"><div class='inline'>
137
+ <p>Define your JSONAPI configuration.</p>
138
+ </div></span>
139
+
140
+ </li>
141
+
142
+
143
+ </ul>
144
+
145
+ <h2>
146
+ Instance Method Summary
147
+ <small><a href="#" class="summary_toggle">collapse</a></small>
148
+ </h2>
149
+
150
+ <ul class="summary">
151
+
152
+ <li class="public ">
153
+ <span class="summary_signature">
154
+
155
+ <a href="#default_jsonapi_render_options-instance_method" title="#default_jsonapi_render_options (instance method)">#<strong>default_jsonapi_render_options</strong> &#x21d2; Hash </a>
156
+
157
+
158
+
159
+ </span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'>
170
+ <p>Define a hash that will be automatically merged into your render_jsonapi
171
+ call.</p>
172
+ </div></span>
173
+
174
+ </li>
175
+
176
+
177
+ <li class="public ">
178
+ <span class="summary_signature">
179
+
180
+ <a href="#deserialized_params-instance_method" title="#deserialized_params (instance method)">#<strong>deserialized_params</strong> &#x21d2; Deserializer </a>
181
+
182
+
183
+
184
+ </span>
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+ <span class="summary_desc"><div class='inline'></div></span>
195
+
196
+ </li>
197
+
198
+
199
+ <li class="public ">
200
+ <span class="summary_signature">
201
+
202
+ <a href="#jsonapi_create-instance_method" title="#jsonapi_create (instance method)">#<strong>jsonapi_create</strong> &#x21d2; Util::ValidationResponse </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>Create the resource model and process all nested relationships via the
218
+ serialized parameters.</p>
219
+ </div></span>
220
+
221
+ </li>
222
+
223
+
224
+ <li class="public ">
225
+ <span class="summary_signature">
226
+
227
+ <a href="#jsonapi_scope-instance_method" title="#jsonapi_scope (instance method)">#<strong>jsonapi_scope</strong>(scope, opts = {}) &#x21d2; Scope </a>
228
+
229
+
230
+
231
+ </span>
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+ <span class="summary_desc"><div class='inline'>
242
+ <p>Use when direct, low-level access to the scope is required.</p>
243
+ </div></span>
244
+
245
+ </li>
246
+
247
+
248
+ <li class="public ">
249
+ <span class="summary_signature">
250
+
251
+ <a href="#jsonapi_update-instance_method" title="#jsonapi_update (instance method)">#<strong>jsonapi_update</strong> &#x21d2; Util::ValidationResponse </a>
252
+
253
+
254
+
255
+ </span>
256
+
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+ <span class="summary_desc"><div class='inline'>
266
+ <p>Update the resource model and process all nested relationships via the
267
+ serialized parameters.</p>
268
+ </div></span>
269
+
270
+ </li>
271
+
272
+
273
+ <li class="public ">
274
+ <span class="summary_signature">
275
+
276
+ <a href="#query-instance_method" title="#query (instance method)">#<strong>query</strong> &#x21d2; Query </a>
277
+
278
+
279
+
280
+ </span>
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+
289
+
290
+ <span class="summary_desc"><div class='inline'>
291
+ <p>Instantiates the relevant Query object.</p>
292
+ </div></span>
293
+
294
+ </li>
295
+
296
+
297
+ <li class="public ">
298
+ <span class="summary_signature">
299
+
300
+ <a href="#query_hash-instance_method" title="#query_hash (instance method)">#<strong>query_hash</strong> &#x21d2; Hash </a>
301
+
302
+
303
+
304
+ </span>
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+ <span class="summary_desc"><div class='inline'>
315
+ <p>The normalized query hash for only the <strong>current</strong> resource.</p>
316
+ </div></span>
317
+
318
+ </li>
319
+
320
+
321
+ <li class="public ">
322
+ <span class="summary_signature">
323
+
324
+ <a href="#render_jsonapi-instance_method" title="#render_jsonapi (instance method)">#<strong>render_jsonapi</strong>(scope, opts = {}) &#x21d2; Object </a>
325
+
326
+
327
+
328
+ </span>
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+
337
+
338
+ <span class="summary_desc"><div class='inline'>
339
+ <p>Similar to <tt>render :json</tt> or <tt>render :jsonapi</tt>.</p>
340
+ </div></span>
341
+
342
+ </li>
343
+
344
+
345
+ <li class="public ">
346
+ <span class="summary_signature">
347
+
348
+ <a href="#resource-instance_method" title="#resource (instance method)">#<strong>resource</strong> &#x21d2; Resource </a>
349
+
350
+
351
+
352
+ </span>
353
+
354
+
355
+
356
+
357
+
358
+
359
+
360
+
361
+
362
+ <span class="summary_desc"><div class='inline'>
363
+ <p>Returns an instance of the associated Resource.</p>
364
+ </div></span>
365
+
366
+ </li>
367
+
368
+
369
+ <li class="public ">
370
+ <span class="summary_signature">
371
+
372
+ <a href="#wrap_context-instance_method" title="#wrap_context (instance method)">#<strong>wrap_context</strong> &#x21d2; Object </a>
373
+
374
+
375
+
376
+ </span>
377
+
378
+
379
+
380
+
381
+
382
+
383
+ <span class="private note title">private</span>
384
+
385
+
386
+ <span class="summary_desc"><div class='inline'>
387
+ <p>Tracks the current context so we can refer to it within any random object.</p>
388
+ </div></span>
389
+
390
+ </li>
391
+
392
+
393
+ </ul>
394
+
395
+
396
+
397
+
398
+
399
+ <div id="class_method_details" class="method_details_list">
400
+ <h2>Class Method Details</h2>
401
+
402
+
403
+ <div class="method_details first">
404
+ <h3 class="signature first" id="jsonapi-class_method">
405
+
406
+ .<strong>jsonapi</strong>(foo = &#39;bar&#39;, resource: nil, &amp;blk) &#x21d2; <tt>void</tt>
407
+
408
+
409
+
410
+
411
+
412
+ </h3><div class="docstring">
413
+ <div class="discussion">
414
+ <p class="note returns_void">This method returns an undefined value.</p>
415
+ <p>Define your JSONAPI configuration</p>
416
+
417
+
418
+ </div>
419
+ </div>
420
+ <div class="tags">
421
+
422
+ <div class="examples">
423
+ <p class="tag_title">Examples:</p>
424
+
425
+
426
+ <p class="example_title"><div class='inline'>
427
+ <p>Inline Resource</p>
428
+ </div></p>
429
+
430
+ <pre class="example code"><code><span class='comment'># &#39;Quick and Dirty&#39; solution that does not require a separate
431
+ </span><span class='comment'># Resource object
432
+ </span><span class='kw'>class</span> <span class='const'>PostsController</span> <span class='op'>&lt;</span> <span class='const'>ApplicationController</span>
433
+ <span class='id identifier rubyid_jsonapi'>jsonapi</span> <span class='kw'>do</span>
434
+ <span class='id identifier rubyid_type'>type</span> <span class='symbol'>:posts</span>
435
+ <span class='id identifier rubyid_use_adapter'>use_adapter</span> <span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Adapters/ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span></span>
436
+
437
+ <span class='id identifier rubyid_allow_filter'>allow_filter</span> <span class='symbol'>:title</span>
438
+ <span class='kw'>end</span>
439
+ <span class='kw'>end</span></code></pre>
440
+
441
+
442
+ <p class="example_title"><div class='inline'>
443
+ <p>Resource Class (preferred)</p>
444
+ </div></p>
445
+
446
+ <pre class="example code"><code><span class='comment'># Make code reusable by encapsulating it in a Resource class
447
+ </span><span class='kw'>class</span> <span class='const'>PostsController</span> <span class='op'>&lt;</span> <span class='const'>ApplicationController</span>
448
+ <span class='id identifier rubyid_jsonapi'>jsonapi</span> <span class='label'>resource:</span> <span class='const'>PostResource</span>
449
+ <span class='kw'>end</span></code></pre>
450
+
451
+ </div>
452
+ <p class="tag_title">Parameters:</p>
453
+ <ul class="param">
454
+
455
+ <li>
456
+
457
+ <span class='name'>resource</span>
458
+
459
+
460
+ <span class='type'>(<tt><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></tt>)</span>
461
+
462
+
463
+
464
+ &mdash;
465
+ <div class='inline'>
466
+ <p>the Resource class associated to this endpoint</p>
467
+ </div>
468
+
469
+ </li>
470
+
471
+ </ul>
472
+
473
+
474
+ <p class="tag_title">See Also:</p>
475
+ <ul class="see">
476
+
477
+ <li><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></li>
478
+
479
+ </ul>
480
+
481
+ </div><table class="source_code">
482
+ <tr>
483
+ <td>
484
+ <pre class="lines">
485
+
486
+
487
+ 44
488
+ 45
489
+ 46
490
+ 47
491
+ 48
492
+ 49
493
+ 50
494
+ 51
495
+ 52
496
+ 53
497
+ 54</pre>
498
+ </td>
499
+ <td>
500
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 44</span>
501
+
502
+ <span class='kw'>def</span> <span class='id identifier rubyid_jsonapi'>jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_foo'>foo</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>bar</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
503
+ <span class='kw'>if</span> <span class='id identifier rubyid_resource'>resource</span>
504
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span>
505
+ <span class='kw'>else</span>
506
+ <span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span>
507
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span> <span class='op'>=</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></span><span class='rparen'>)</span>
508
+ <span class='kw'>end</span>
509
+ <span class='kw'>end</span>
510
+
511
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_blk'>blk</span>
512
+ <span class='kw'>end</span></pre>
513
+ </td>
514
+ </tr>
515
+ </table>
516
+ </div>
517
+
518
+ </div>
519
+
520
+ <div id="instance_method_details" class="method_details_list">
521
+ <h2>Instance Method Details</h2>
522
+
523
+
524
+ <div class="method_details first">
525
+ <h3 class="signature first" id="default_jsonapi_render_options-instance_method">
526
+
527
+ #<strong>default_jsonapi_render_options</strong> &#x21d2; <tt>Hash</tt>
528
+
529
+
530
+
531
+
532
+
533
+ </h3><div class="docstring">
534
+ <div class="discussion">
535
+
536
+ <p>Define a hash that will be automatically merged into your render_jsonapi
537
+ call</p>
538
+
539
+
540
+ </div>
541
+ </div>
542
+ <div class="tags">
543
+
544
+ <div class="examples">
545
+ <p class="tag_title">Examples:</p>
546
+
547
+
548
+ <pre class="example code"><code># this
549
+ render_jsonapi(foo)
550
+ # is equivalent to this
551
+ render jsonapi: foo, default_jsonapi_render_options</code></pre>
552
+
553
+ </div>
554
+
555
+ <p class="tag_title">Returns:</p>
556
+ <ul class="return">
557
+
558
+ <li>
559
+
560
+
561
+ <span class='type'>(<tt>Hash</tt>)</span>
562
+
563
+
564
+
565
+ &mdash;
566
+ <div class='inline'>
567
+ <p>the options hash you define</p>
568
+ </div>
569
+
570
+ </li>
571
+
572
+ </ul>
573
+
574
+ <p class="tag_title">See Also:</p>
575
+ <ul class="see">
576
+
577
+ <li><span class='object_link'><a href="#render_jsonapi-instance_method" title="JsonapiCompliable::Base#render_jsonapi (method)">#render_jsonapi</a></span></li>
578
+
579
+ </ul>
580
+
581
+ </div><table class="source_code">
582
+ <tr>
583
+ <td>
584
+ <pre class="lines">
585
+
586
+
587
+ 240
588
+ 241
589
+ 242
590
+ 243</pre>
591
+ </td>
592
+ <td>
593
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 240</span>
594
+
595
+ <span class='kw'>def</span> <span class='id identifier rubyid_default_jsonapi_render_options'>default_jsonapi_render_options</span>
596
+ <span class='lbrace'>{</span><span class='rbrace'>}</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_options'>options</span><span class='op'>|</span>
597
+ <span class='kw'>end</span>
598
+ <span class='kw'>end</span></pre>
599
+ </td>
600
+ </tr>
601
+ </table>
602
+ </div>
603
+
604
+ <div class="method_details ">
605
+ <h3 class="signature " id="deserialized_params-instance_method">
606
+
607
+ #<strong>deserialized_params</strong> &#x21d2; <tt><span class='object_link'><a href="Deserializer.html" title="JsonapiCompliable::Deserializer (class)">Deserializer</a></span></tt>
608
+
609
+
610
+
611
+
612
+
613
+ </h3><div class="docstring">
614
+ <div class="discussion">
615
+
616
+
617
+ </div>
618
+ </div>
619
+ <div class="tags">
620
+
621
+ <p class="tag_title">Returns:</p>
622
+ <ul class="return">
623
+
624
+ <li>
625
+
626
+
627
+ <span class='type'>(<tt><span class='object_link'><a href="Deserializer.html" title="JsonapiCompliable::Deserializer (class)">Deserializer</a></span></tt>)</span>
628
+
629
+
630
+
631
+ </li>
632
+
633
+ </ul>
634
+
635
+ <p class="tag_title">See Also:</p>
636
+ <ul class="see">
637
+
638
+ <li><span class='object_link'><a href="Deserializer.html#initialize-instance_method" title="JsonapiCompliable::Deserializer#initialize (method)">Deserializer#initialize</a></span></li>
639
+
640
+ </ul>
641
+
642
+ </div><table class="source_code">
643
+ <tr>
644
+ <td>
645
+ <pre class="lines">
646
+
647
+
648
+ 121
649
+ 122
650
+ 123</pre>
651
+ </td>
652
+ <td>
653
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 121</span>
654
+
655
+ <span class='kw'>def</span> <span class='id identifier rubyid_deserialized_params'>deserialized_params</span>
656
+ <span class='ivar'>@deserialized_params</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Deserializer.html" title="JsonapiCompliable::Deserializer (class)">Deserializer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Deserializer.html#initialize-instance_method" title="JsonapiCompliable::Deserializer#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='comma'>,</span> <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
657
+ <span class='kw'>end</span></pre>
658
+ </td>
659
+ </tr>
660
+ </table>
661
+ </div>
662
+
663
+ <div class="method_details ">
664
+ <h3 class="signature " id="jsonapi_create-instance_method">
665
+
666
+ #<strong>jsonapi_create</strong> &#x21d2; <tt><span class='object_link'><a href="Util/ValidationResponse.html" title="JsonapiCompliable::Util::ValidationResponse (class)">Util::ValidationResponse</a></span></tt>
667
+
668
+
669
+
670
+
671
+
672
+ </h3><div class="docstring">
673
+ <div class="discussion">
674
+
675
+ <p>Create the resource model and process all nested relationships via the
676
+ serialized parameters. Any error, including validation errors, will roll
677
+ back the transaction.</p>
678
+
679
+
680
+ </div>
681
+ </div>
682
+ <div class="tags">
683
+
684
+ <div class="examples">
685
+ <p class="tag_title">Examples:</p>
686
+
687
+
688
+ <p class="example_title"><div class='inline'>
689
+ <p>Basic Rails</p>
690
+ </div></p>
691
+
692
+ <pre class="example code"><code><span class='comment'># Example Resource must have &#39;model&#39;
693
+ </span><span class='comment'>#
694
+ </span><span class='comment'># class PostResource &lt; ApplicationResource
695
+ </span><span class='comment'># model Post
696
+ </span><span class='comment'># end
697
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span>
698
+ <span class='id identifier rubyid_post'>post</span><span class='comma'>,</span> <span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_create'>jsonapi_create</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
699
+
700
+ <span class='kw'>if</span> <span class='id identifier rubyid_success'>success</span>
701
+ <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>false</span><span class='rparen'>)</span>
702
+ <span class='kw'>else</span>
703
+ <span class='id identifier rubyid_render_errors_for'>render_errors_for</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='rparen'>)</span>
704
+ <span class='kw'>end</span>
705
+ <span class='kw'>end</span></code></pre>
706
+
707
+ </div>
708
+
709
+ <p class="tag_title">Returns:</p>
710
+ <ul class="return">
711
+
712
+ <li>
713
+
714
+
715
+ <span class='type'>(<tt><span class='object_link'><a href="Util/ValidationResponse.html" title="JsonapiCompliable::Util::ValidationResponse (class)">Util::ValidationResponse</a></span></tt>)</span>
716
+
717
+
718
+
719
+ </li>
720
+
721
+ </ul>
722
+
723
+ <p class="tag_title">See Also:</p>
724
+ <ul class="see">
725
+
726
+ <li><span class='object_link'><a href="Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
727
+
728
+ <li><span class='object_link'><a href="#resource-instance_method" title="JsonapiCompliable::Base#resource (method)">#resource</a></span></li>
729
+
730
+ <li><span class='object_link'><a href="#deserialized_params-instance_method" title="JsonapiCompliable::Base#deserialized_params (method)">#deserialized_params</a></span></li>
731
+
732
+ </ul>
733
+
734
+ </div><table class="source_code">
735
+ <tr>
736
+ <td>
737
+ <pre class="lines">
738
+
739
+
740
+ 149
741
+ 150
742
+ 151
743
+ 152
744
+ 153
745
+ 154
746
+ 155
747
+ 156</pre>
748
+ </td>
749
+ <td>
750
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 149</span>
751
+
752
+ <span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_create'>jsonapi_create</span>
753
+ <span class='id identifier rubyid__persist'>_persist</span> <span class='kw'>do</span>
754
+ <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_persist_with_relationships'>persist_with_relationships</span> \
755
+ <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_meta'>meta</span><span class='comma'>,</span>
756
+ <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_attributes'>attributes</span><span class='comma'>,</span>
757
+ <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_relationships'>relationships</span>
758
+ <span class='kw'>end</span>
759
+ <span class='kw'>end</span></pre>
760
+ </td>
761
+ </tr>
762
+ </table>
763
+ </div>
764
+
765
+ <div class="method_details ">
766
+ <h3 class="signature " id="jsonapi_scope-instance_method">
767
+
768
+ #<strong>jsonapi_scope</strong>(scope, opts = {}) &#x21d2; <tt><span class='object_link'><a href="Scope.html" title="JsonapiCompliable::Scope (class)">Scope</a></span></tt>
769
+
770
+
771
+
772
+
773
+
774
+ </h3><div class="docstring">
775
+ <div class="discussion">
776
+
777
+ <p>Use when direct, low-level access to the scope is required.</p>
778
+
779
+
780
+ </div>
781
+ </div>
782
+ <div class="tags">
783
+
784
+ <div class="examples">
785
+ <p class="tag_title">Examples:</p>
786
+
787
+
788
+ <p class="example_title"><div class='inline'>
789
+ <p>Show Action</p>
790
+ </div></p>
791
+
792
+ <pre class="example code"><code><span class='comment'># Scope#resolve returns an array, but we only want to render
793
+ </span><span class='comment'># one object, not an array
794
+ </span><span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='const'>Employee</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>id:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:id</span><span class='rbracket'>]</span><span class='rparen'>)</span><span class='rparen'>)</span>
795
+ <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>false</span><span class='rparen'>)</span></code></pre>
796
+
797
+
798
+ <p class="example_title"><div class='inline'>
799
+ <p>Scope Chaining</p>
800
+ </div></p>
801
+
802
+ <pre class="example code"><code><span class='comment'># Chain onto scope after running through typical DSL
803
+ </span><span class='comment'># Here, we&#39;ll add active: true to our hash if the user
804
+ </span><span class='comment'># is filtering on something
805
+ </span><span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
806
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='label'>active:</span> <span class='kw'>true</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span><span class='lbracket'>[</span><span class='symbol'>:filter</span><span class='rbracket'>]</span></code></pre>
807
+
808
+ </div>
809
+
810
+ <p class="tag_title">Returns:</p>
811
+ <ul class="return">
812
+
813
+ <li>
814
+
815
+
816
+ <span class='type'>(<tt><span class='object_link'><a href="Scope.html" title="JsonapiCompliable::Scope (class)">Scope</a></span></tt>)</span>
817
+
818
+
819
+
820
+ &mdash;
821
+ <div class='inline'>
822
+ <p>the configured scope</p>
823
+ </div>
824
+
825
+ </li>
826
+
827
+ </ul>
828
+
829
+ <p class="tag_title">See Also:</p>
830
+ <ul class="see">
831
+
832
+ <li><span class='object_link'><a href="Resource.html#build_scope-instance_method" title="JsonapiCompliable::Resource#build_scope (method)">Resource#build_scope</a></span></li>
833
+
834
+ </ul>
835
+
836
+ </div><table class="source_code">
837
+ <tr>
838
+ <td>
839
+ <pre class="lines">
840
+
841
+
842
+ 115
843
+ 116
844
+ 117</pre>
845
+ </td>
846
+ <td>
847
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 115</span>
848
+
849
+ <span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
850
+ <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_build_scope'>build_scope</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
851
+ <span class='kw'>end</span></pre>
852
+ </td>
853
+ </tr>
854
+ </table>
855
+ </div>
856
+
857
+ <div class="method_details ">
858
+ <h3 class="signature " id="jsonapi_update-instance_method">
859
+
860
+ #<strong>jsonapi_update</strong> &#x21d2; <tt><span class='object_link'><a href="Util/ValidationResponse.html" title="JsonapiCompliable::Util::ValidationResponse (class)">Util::ValidationResponse</a></span></tt>
861
+
862
+
863
+
864
+
865
+
866
+ </h3><div class="docstring">
867
+ <div class="discussion">
868
+
869
+ <p>Update the resource model and process all nested relationships via the
870
+ serialized parameters. Any error, including validation errors, will roll
871
+ back the transaction.</p>
872
+
873
+
874
+ </div>
875
+ </div>
876
+ <div class="tags">
877
+
878
+ <div class="examples">
879
+ <p class="tag_title">Examples:</p>
880
+
881
+
882
+ <p class="example_title"><div class='inline'>
883
+ <p>Basic Rails</p>
884
+ </div></p>
885
+
886
+ <pre class="example code"><code><span class='comment'># Example Resource must have &#39;model&#39;
887
+ </span><span class='comment'>#
888
+ </span><span class='comment'># class PostResource &lt; ApplicationResource
889
+ </span><span class='comment'># model Post
890
+ </span><span class='comment'># end
891
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span>
892
+ <span class='id identifier rubyid_post'>post</span><span class='comma'>,</span> <span class='id identifier rubyid_success'>success</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_update'>jsonapi_update</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
893
+
894
+ <span class='kw'>if</span> <span class='id identifier rubyid_success'>success</span>
895
+ <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>false</span><span class='rparen'>)</span>
896
+ <span class='kw'>else</span>
897
+ <span class='id identifier rubyid_render_errors_for'>render_errors_for</span><span class='lparen'>(</span><span class='id identifier rubyid_post'>post</span><span class='rparen'>)</span>
898
+ <span class='kw'>end</span>
899
+ <span class='kw'>end</span></code></pre>
900
+
901
+ </div>
902
+
903
+ <p class="tag_title">Returns:</p>
904
+ <ul class="return">
905
+
906
+ <li>
907
+
908
+
909
+ <span class='type'>(<tt><span class='object_link'><a href="Util/ValidationResponse.html" title="JsonapiCompliable::Util::ValidationResponse (class)">Util::ValidationResponse</a></span></tt>)</span>
910
+
911
+
912
+
913
+ </li>
914
+
915
+ </ul>
916
+
917
+ <p class="tag_title">See Also:</p>
918
+ <ul class="see">
919
+
920
+ <li><span class='object_link'><a href="#jsonapi_create-instance_method" title="JsonapiCompliable::Base#jsonapi_create (method)">#jsonapi_create</a></span></li>
921
+
922
+ </ul>
923
+
924
+ </div><table class="source_code">
925
+ <tr>
926
+ <td>
927
+ <pre class="lines">
928
+
929
+
930
+ 180
931
+ 181
932
+ 182
933
+ 183
934
+ 184
935
+ 185
936
+ 186
937
+ 187</pre>
938
+ </td>
939
+ <td>
940
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 180</span>
941
+
942
+ <span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_update'>jsonapi_update</span>
943
+ <span class='id identifier rubyid__persist'>_persist</span> <span class='kw'>do</span>
944
+ <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_persist_with_relationships'>persist_with_relationships</span> \
945
+ <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_meta'>meta</span><span class='comma'>,</span>
946
+ <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_attributes'>attributes</span><span class='comma'>,</span>
947
+ <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_relationships'>relationships</span>
948
+ <span class='kw'>end</span>
949
+ <span class='kw'>end</span></pre>
950
+ </td>
951
+ </tr>
952
+ </table>
953
+ </div>
954
+
955
+ <div class="method_details ">
956
+ <h3 class="signature " id="query-instance_method">
957
+
958
+ #<strong>query</strong> &#x21d2; <tt><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></tt>
959
+
960
+
961
+
962
+
963
+
964
+ </h3><div class="docstring">
965
+ <div class="discussion">
966
+
967
+ <p>Instantiates the relevant Query object</p>
968
+
969
+
970
+ </div>
971
+ </div>
972
+ <div class="tags">
973
+
974
+ <p class="tag_title">Returns:</p>
975
+ <ul class="return">
976
+
977
+ <li>
978
+
979
+
980
+ <span class='type'>(<tt><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></tt>)</span>
981
+
982
+
983
+
984
+ &mdash;
985
+ <div class='inline'>
986
+ <p>the Query object for this resource/params</p>
987
+ </div>
988
+
989
+ </li>
990
+
991
+ </ul>
992
+
993
+ <p class="tag_title">See Also:</p>
994
+ <ul class="see">
995
+
996
+ <li><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></li>
997
+
998
+ </ul>
999
+
1000
+ </div><table class="source_code">
1001
+ <tr>
1002
+ <td>
1003
+ <pre class="lines">
1004
+
1005
+
1006
+ 74
1007
+ 75
1008
+ 76</pre>
1009
+ </td>
1010
+ <td>
1011
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 74</span>
1012
+
1013
+ <span class='kw'>def</span> <span class='id identifier rubyid_query'>query</span>
1014
+ <span class='ivar'>@query</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Query.html#initialize-instance_method" title="JsonapiCompliable::Query#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
1015
+ <span class='kw'>end</span></pre>
1016
+ </td>
1017
+ </tr>
1018
+ </table>
1019
+ </div>
1020
+
1021
+ <div class="method_details ">
1022
+ <h3 class="signature " id="query_hash-instance_method">
1023
+
1024
+ #<strong>query_hash</strong> &#x21d2; <tt>Hash</tt>
1025
+
1026
+
1027
+
1028
+
1029
+
1030
+ </h3><div class="docstring">
1031
+ <div class="discussion">
1032
+
1033
+ <p>Returns the normalized query hash for only the <strong>current</strong>
1034
+ resource</p>
1035
+
1036
+
1037
+ </div>
1038
+ </div>
1039
+ <div class="tags">
1040
+
1041
+ <p class="tag_title">Returns:</p>
1042
+ <ul class="return">
1043
+
1044
+ <li>
1045
+
1046
+
1047
+ <span class='type'>(<tt>Hash</tt>)</span>
1048
+
1049
+
1050
+
1051
+ &mdash;
1052
+ <div class='inline'>
1053
+ <p>the normalized query hash for only the <strong>current</strong> resource</p>
1054
+ </div>
1055
+
1056
+ </li>
1057
+
1058
+ </ul>
1059
+
1060
+ <p class="tag_title">See Also:</p>
1061
+ <ul class="see">
1062
+
1063
+ <li><span class='object_link'><a href="Query.html#to_hash-instance_method" title="JsonapiCompliable::Query#to_hash (method)">Query#to_hash</a></span></li>
1064
+
1065
+ </ul>
1066
+
1067
+ </div><table class="source_code">
1068
+ <tr>
1069
+ <td>
1070
+ <pre class="lines">
1071
+
1072
+
1073
+ 80
1074
+ 81
1075
+ 82</pre>
1076
+ </td>
1077
+ <td>
1078
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 80</span>
1079
+
1080
+ <span class='kw'>def</span> <span class='id identifier rubyid_query_hash'>query_hash</span>
1081
+ <span class='ivar'>@query_hash</span> <span class='op'>||=</span> <span class='id identifier rubyid_query'>query</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span>
1082
+ <span class='kw'>end</span></pre>
1083
+ </td>
1084
+ </tr>
1085
+ </table>
1086
+ </div>
1087
+
1088
+ <div class="method_details ">
1089
+ <h3 class="signature " id="render_jsonapi-instance_method">
1090
+
1091
+ #<strong>render_jsonapi</strong>(scope, opts = {}) &#x21d2; <tt>Object</tt>
1092
+
1093
+
1094
+
1095
+
1096
+
1097
+ </h3><div class="docstring">
1098
+ <div class="discussion">
1099
+
1100
+ <p>Similar to <tt>render :json</tt> or <tt>render :jsonapi</tt></p>
1101
+
1102
+ <p>By default, this will “build” the scope via <code>#jsonapi_scope</code>. To
1103
+ avoid this, pass <tt>scope: false</tt></p>
1104
+
1105
+ <p>This builds relevant options and sends them to
1106
+ <tt>JSONAPI::Serializable::Renderer.render</tt>from <a href="http://jsonapi-rb.org" target="_parent" title="jsonapi-rb">jsonapi-rb</a></p>
1107
+
1108
+
1109
+ </div>
1110
+ </div>
1111
+ <div class="tags">
1112
+
1113
+ <div class="examples">
1114
+ <p class="tag_title">Examples:</p>
1115
+
1116
+
1117
+ <p class="example_title"><div class='inline'>
1118
+ <p>Build Scope by Default</p>
1119
+ </div></p>
1120
+
1121
+ <pre class="example code"><code><span class='comment'># Employee.all returns an ActiveRecord::Relation. No SQL is fired at this point.
1122
+ </span><span class='comment'># We further &#39;chain&#39; onto this scope, applying pagination, sorting,
1123
+ </span><span class='comment'># filters, etc that the user has requested.
1124
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_index'>index</span>
1125
+ <span class='id identifier rubyid_employees'>employees</span> <span class='op'>=</span> <span class='const'>Employee</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
1126
+ <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_employees'>employees</span><span class='rparen'>)</span>
1127
+ <span class='kw'>end</span></code></pre>
1128
+
1129
+
1130
+ <p class="example_title"><div class='inline'>
1131
+ <p>Avoid Building Scope by Default</p>
1132
+ </div></p>
1133
+
1134
+ <pre class="example code"><code><span class='comment'># Maybe we already manually scoped, and don&#39;t want to fire the logic twice
1135
+ </span><span class='comment'># This code is equivalent to the above example
1136
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_index'>index</span>
1137
+ <span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='const'>Employee</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span><span class='rparen'>)</span>
1138
+ <span class='comment'># ... do other things with the scope ...
1139
+ </span> <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>false</span><span class='rparen'>)</span>
1140
+ <span class='kw'>end</span></code></pre>
1141
+
1142
+ </div>
1143
+ <p class="tag_title">Parameters:</p>
1144
+ <ul class="param">
1145
+
1146
+ <li>
1147
+
1148
+ <span class='name'>scope</span>
1149
+
1150
+
1151
+ <span class='type'>(<tt><span class='object_link'><a href="Scope.html" title="JsonapiCompliable::Scope (class)">Scope</a></span></tt>, <tt>Object</tt>)</span>
1152
+
1153
+
1154
+
1155
+ &mdash;
1156
+ <div class='inline'>
1157
+ <p>the scope to build or render.</p>
1158
+ </div>
1159
+
1160
+ </li>
1161
+
1162
+ <li>
1163
+
1164
+ <span class='name'>opts</span>
1165
+
1166
+
1167
+ <span class='type'>(<tt>Hash</tt>)</span>
1168
+
1169
+
1170
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1171
+
1172
+
1173
+ &mdash;
1174
+ <div class='inline'>
1175
+ <p>the render options passed to <a href="http://jsonapi-rb.org" target="_parent" title="jsonapi-rb">jsonapi-rb</a></p>
1176
+ </div>
1177
+
1178
+ </li>
1179
+
1180
+ </ul>
1181
+
1182
+
1183
+
1184
+
1185
+
1186
+
1187
+ <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
1188
+ <ul class="option">
1189
+
1190
+ <li>
1191
+ <span class="name">:scope</span>
1192
+ <span class="type">(<tt>Boolean</tt>)</span>
1193
+ <span class="default">
1194
+
1195
+ </span>
1196
+
1197
+ &mdash; <div class='inline'>
1198
+ <p>Default: true. Should we call #jsonapi_scope on this object?</p>
1199
+ </div>
1200
+
1201
+ </li>
1202
+
1203
+ </ul>
1204
+
1205
+
1206
+
1207
+ <p class="tag_title">See Also:</p>
1208
+ <ul class="see">
1209
+
1210
+ <li><span class='object_link'><a href="#jsonapi_scope-instance_method" title="JsonapiCompliable::Base#jsonapi_scope (method)">#jsonapi_scope</a></span></li>
1211
+
1212
+ </ul>
1213
+
1214
+ </div><table class="source_code">
1215
+ <tr>
1216
+ <td>
1217
+ <pre class="lines">
1218
+
1219
+
1220
+ 220
1221
+ 221
1222
+ 222
1223
+ 223
1224
+ 224
1225
+ 225
1226
+ 226
1227
+ 227</pre>
1228
+ </td>
1229
+ <td>
1230
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 220</span>
1231
+
1232
+ <span class='kw'>def</span> <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
1233
+ <span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:scope</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='kw'>false</span> <span class='op'>||</span> <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Scope.html" title="JsonapiCompliable::Scope (class)">Scope</a></span></span><span class='rparen'>)</span>
1234
+ <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='id identifier rubyid_default_jsonapi_render_options'>default_jsonapi_render_options</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1235
+ <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="Util.html" title="JsonapiCompliable::Util (module)">Util</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util/RenderOptions.html" title="JsonapiCompliable::Util::RenderOptions (class)">RenderOptions</a></span></span><span class='period'>.</span><span class='id identifier rubyid_generate'><span class='object_link'><a href="Util/RenderOptions.html#generate-class_method" title="JsonapiCompliable::Util::RenderOptions.generate (method)">generate</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_query_hash'>query_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1236
+ <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:expose</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:context</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>self</span>
1237
+ <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:include</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_deserialized_params'>deserialized_params</span><span class='period'>.</span><span class='id identifier rubyid_include_directive'>include_directive</span> <span class='kw'>if</span> <span class='id identifier rubyid_force_includes?'>force_includes?</span>
1238
+ <span class='id identifier rubyid_perform_render_jsonapi'>perform_render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1239
+ <span class='kw'>end</span></pre>
1240
+ </td>
1241
+ </tr>
1242
+ </table>
1243
+ </div>
1244
+
1245
+ <div class="method_details ">
1246
+ <h3 class="signature " id="resource-instance_method">
1247
+
1248
+ #<strong>resource</strong> &#x21d2; <tt><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></tt>
1249
+
1250
+
1251
+
1252
+
1253
+
1254
+ </h3><div class="docstring">
1255
+ <div class="discussion">
1256
+
1257
+ <p>Returns an instance of the associated Resource</p>
1258
+
1259
+ <p>In other words, if you configured your controller as:</p>
1260
+
1261
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_jsonapi'>jsonapi</span> <span class='label'>resource:</span> <span class='const'>MyResource</span>
1262
+ </code></pre>
1263
+
1264
+ <p>This returns MyResource.new</p>
1265
+
1266
+
1267
+ </div>
1268
+ </div>
1269
+ <div class="tags">
1270
+
1271
+ <p class="tag_title">Returns:</p>
1272
+ <ul class="return">
1273
+
1274
+ <li>
1275
+
1276
+
1277
+ <span class='type'>(<tt><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></tt>)</span>
1278
+
1279
+
1280
+
1281
+ &mdash;
1282
+ <div class='inline'>
1283
+ <p>the configured Resource for this controller</p>
1284
+ </div>
1285
+
1286
+ </li>
1287
+
1288
+ </ul>
1289
+
1290
+ </div><table class="source_code">
1291
+ <tr>
1292
+ <td>
1293
+ <pre class="lines">
1294
+
1295
+
1296
+ 66
1297
+ 67
1298
+ 68</pre>
1299
+ </td>
1300
+ <td>
1301
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 66</span>
1302
+
1303
+ <span class='kw'>def</span> <span class='id identifier rubyid_resource'>resource</span>
1304
+ <span class='ivar'>@resource</span> <span class='op'>||=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
1305
+ <span class='kw'>end</span></pre>
1306
+ </td>
1307
+ </tr>
1308
+ </table>
1309
+ </div>
1310
+
1311
+ <div class="method_details ">
1312
+ <h3 class="signature " id="wrap_context-instance_method">
1313
+
1314
+ #<strong>wrap_context</strong> &#x21d2; <tt>Object</tt>
1315
+
1316
+
1317
+
1318
+
1319
+
1320
+ </h3><div class="docstring">
1321
+ <div class="discussion">
1322
+ <p class="note private">
1323
+ <strong>This method is part of a private API.</strong>
1324
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
1325
+ </p>
1326
+
1327
+ <p>Tracks the current context so we can refer to it within any random object.
1328
+ Helpful for easy-access to things like the current user.</p>
1329
+
1330
+
1331
+ </div>
1332
+ </div>
1333
+ <div class="tags">
1334
+
1335
+ <p class="tag_title">Yield Returns:</p>
1336
+ <ul class="yieldreturn">
1337
+
1338
+ <li>
1339
+
1340
+
1341
+ <span class='type'></span>
1342
+
1343
+
1344
+
1345
+
1346
+ <div class='inline'>
1347
+ <p>Code to run within the current context</p>
1348
+ </div>
1349
+
1350
+ </li>
1351
+
1352
+ </ul>
1353
+
1354
+ </div><table class="source_code">
1355
+ <tr>
1356
+ <td>
1357
+ <pre class="lines">
1358
+
1359
+
1360
+ 90
1361
+ 91
1362
+ 92
1363
+ 93
1364
+ 94
1365
+ 95
1366
+ 96</pre>
1367
+ </td>
1368
+ <td>
1369
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 90</span>
1370
+
1371
+ <span class='kw'>def</span> <span class='id identifier rubyid_wrap_context'>wrap_context</span>
1372
+ <span class='kw'>if</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span>
1373
+ <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_with_context'>with_context</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_action_name'>action_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span> <span class='kw'>do</span>
1374
+ <span class='kw'>yield</span>
1375
+ <span class='kw'>end</span>
1376
+ <span class='kw'>end</span>
1377
+ <span class='kw'>end</span></pre>
1378
+ </td>
1379
+ </tr>
1380
+ </table>
1381
+ </div>
1382
+
1383
+ </div>
1384
+
1385
+ </div>
1386
+
1387
+ <div id="footer">
1388
+ Generated on Fri May 5 15:53:21 2017 by
1389
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1390
+ 0.9.9 (ruby-2.3.0).
1391
+ </div>
1392
+
1393
+ </div>
1394
+ </body>
1395
+ </html>