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,2151 @@
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::Adapters::ActiveRecord
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::Adapters::ActiveRecord";
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 (A)</a> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span>
41
+ &raquo;
42
+ <span class="title">ActiveRecord</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::Adapters::ActiveRecord
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName"><span class='object_link'><a href="Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Abstract</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next"><span class='object_link'><a href="Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Abstract</a></span></li>
78
+
79
+ <li class="next">JsonapiCompliable::Adapters::ActiveRecord</li>
80
+
81
+ </ul>
82
+ <a href="#" class="inheritanceTree">show all</a>
83
+
84
+ </dd>
85
+ </dl>
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+ <dl>
98
+ <dt>Defined in:</dt>
99
+ <dd>lib/jsonapi_compliable/adapters/active_record.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ <p class="tag_title">See Also:</p>
114
+ <ul class="see">
115
+
116
+ <li><span class='object_link'><a href="Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Abstract</a></span></li>
117
+
118
+ </ul>
119
+
120
+ </div>
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+ <h2>
129
+ Instance Method Summary
130
+ <small><a href="#" class="summary_toggle">collapse</a></small>
131
+ </h2>
132
+
133
+ <ul class="summary">
134
+
135
+ <li class="public ">
136
+ <span class="summary_signature">
137
+
138
+ <a href="#associate-instance_method" title="#associate (instance method)">#<strong>associate</strong>(parent, child, association_name, association_type) &#x21d2; Object </a>
139
+
140
+
141
+
142
+ </span>
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+ <span class="summary_desc"><div class='inline'>
153
+ <p>When a has_many relationship, we need to avoid Activerecord implicitly
154
+ firing a query.</p>
155
+ </div></span>
156
+
157
+ </li>
158
+
159
+
160
+ <li class="public ">
161
+ <span class="summary_signature">
162
+
163
+ <a href="#average-instance_method" title="#average (instance method)">#<strong>average</strong>(scope, attr) &#x21d2; Float </a>
164
+
165
+
166
+
167
+ </span>
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+ <span class="summary_desc"><div class='inline'>
178
+ <p>The average of the scope.</p>
179
+ </div></span>
180
+
181
+ </li>
182
+
183
+
184
+ <li class="public ">
185
+ <span class="summary_signature">
186
+
187
+ <a href="#count-instance_method" title="#count (instance method)">#<strong>count</strong>(scope, attr) &#x21d2; Numeric </a>
188
+
189
+
190
+
191
+ </span>
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+ <span class="summary_desc"><div class='inline'>
202
+ <p>The count of the scope.</p>
203
+ </div></span>
204
+
205
+ </li>
206
+
207
+
208
+ <li class="public ">
209
+ <span class="summary_signature">
210
+
211
+ <a href="#create-instance_method" title="#create (instance method)">#<strong>create</strong>(model_class, create_params) &#x21d2; Object </a>
212
+
213
+
214
+
215
+ </span>
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+ <span class="summary_desc"><div class='inline'>
226
+ <p>The model instance just created.</p>
227
+ </div></span>
228
+
229
+ </li>
230
+
231
+
232
+ <li class="public ">
233
+ <span class="summary_signature">
234
+
235
+ <a href="#destroy-instance_method" title="#destroy (instance method)">#<strong>destroy</strong>(model_class, id) &#x21d2; Object </a>
236
+
237
+
238
+
239
+ </span>
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+ <span class="summary_desc"><div class='inline'>
250
+ <p>The model instance just destroyed.</p>
251
+ </div></span>
252
+
253
+ </li>
254
+
255
+
256
+ <li class="public ">
257
+ <span class="summary_signature">
258
+
259
+ <a href="#filter-instance_method" title="#filter (instance method)">#<strong>filter</strong>(scope, attribute, value) &#x21d2; Object </a>
260
+
261
+
262
+
263
+ </span>
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+ <span class="summary_desc"><div class='inline'>
274
+ <p>The scope.</p>
275
+ </div></span>
276
+
277
+ </li>
278
+
279
+
280
+ <li class="public ">
281
+ <span class="summary_signature">
282
+
283
+ <a href="#maximum-instance_method" title="#maximum (instance method)">#<strong>maximum</strong>(scope, attr) &#x21d2; Numeric </a>
284
+
285
+
286
+
287
+ </span>
288
+
289
+
290
+
291
+
292
+
293
+
294
+
295
+
296
+
297
+ <span class="summary_desc"><div class='inline'>
298
+ <p>The maximum value of the scope.</p>
299
+ </div></span>
300
+
301
+ </li>
302
+
303
+
304
+ <li class="public ">
305
+ <span class="summary_signature">
306
+
307
+ <a href="#minimum-instance_method" title="#minimum (instance method)">#<strong>minimum</strong>(scope, attr) &#x21d2; Numeric </a>
308
+
309
+
310
+
311
+ </span>
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+ <span class="summary_desc"><div class='inline'>
322
+ <p>The maximum value of the scope.</p>
323
+ </div></span>
324
+
325
+ </li>
326
+
327
+
328
+ <li class="public ">
329
+ <span class="summary_signature">
330
+
331
+ <a href="#order-instance_method" title="#order (instance method)">#<strong>order</strong>(scope, attribute, direction) &#x21d2; Object </a>
332
+
333
+
334
+
335
+ </span>
336
+
337
+
338
+
339
+
340
+
341
+
342
+
343
+
344
+
345
+ <span class="summary_desc"><div class='inline'>
346
+ <p>The scope.</p>
347
+ </div></span>
348
+
349
+ </li>
350
+
351
+
352
+ <li class="public ">
353
+ <span class="summary_signature">
354
+
355
+ <a href="#paginate-instance_method" title="#paginate (instance method)">#<strong>paginate</strong>(scope, current_page, per_page) &#x21d2; Object </a>
356
+
357
+
358
+
359
+ </span>
360
+
361
+
362
+
363
+
364
+
365
+
366
+
367
+
368
+
369
+ <span class="summary_desc"><div class='inline'>
370
+ <p>The scope.</p>
371
+ </div></span>
372
+
373
+ </li>
374
+
375
+
376
+ <li class="public ">
377
+ <span class="summary_signature">
378
+
379
+ <a href="#resolve-instance_method" title="#resolve (instance method)">#<strong>resolve</strong>(scope) &#x21d2; Object </a>
380
+
381
+
382
+
383
+ </span>
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+ <span class="summary_desc"><div class='inline'>
394
+ <p>Resolve the scope.</p>
395
+ </div></span>
396
+
397
+ </li>
398
+
399
+
400
+ <li class="public ">
401
+ <span class="summary_signature">
402
+
403
+ <a href="#sideloading_module-instance_method" title="#sideloading_module (instance method)">#<strong>sideloading_module</strong> &#x21d2; Object </a>
404
+
405
+
406
+
407
+ </span>
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+
416
+
417
+ <span class="summary_desc"><div class='inline'>
418
+ <p>This module gets mixed in to Sideload classes This is where you define
419
+ methods like has_many, belongs_to etc that wrap the lower-level
420
+ Sideload#allow_sideload.</p>
421
+ </div></span>
422
+
423
+ </li>
424
+
425
+
426
+ <li class="public ">
427
+ <span class="summary_signature">
428
+
429
+ <a href="#sum-instance_method" title="#sum (instance method)">#<strong>sum</strong>(scope, attr) &#x21d2; Numeric </a>
430
+
431
+
432
+
433
+ </span>
434
+
435
+
436
+
437
+
438
+
439
+
440
+
441
+
442
+
443
+ <span class="summary_desc"><div class='inline'>
444
+ <p>The sum of the scope.</p>
445
+ </div></span>
446
+
447
+ </li>
448
+
449
+
450
+ <li class="public ">
451
+ <span class="summary_signature">
452
+
453
+ <a href="#transaction-instance_method" title="#transaction (instance method)">#<strong>transaction</strong>(model_class) &#x21d2; Object </a>
454
+
455
+
456
+
457
+ </span>
458
+
459
+
460
+
461
+
462
+
463
+
464
+
465
+
466
+
467
+ <span class="summary_desc"><div class='inline'>
468
+ <p>Run this write request within an ActiveRecord transaction.</p>
469
+ </div></span>
470
+
471
+ </li>
472
+
473
+
474
+ <li class="public ">
475
+ <span class="summary_signature">
476
+
477
+ <a href="#update-instance_method" title="#update (instance method)">#<strong>update</strong>(model_class, update_params) &#x21d2; Object </a>
478
+
479
+
480
+
481
+ </span>
482
+
483
+
484
+
485
+
486
+
487
+
488
+
489
+
490
+
491
+ <span class="summary_desc"><div class='inline'>
492
+ <p>The model instance just created.</p>
493
+ </div></span>
494
+
495
+ </li>
496
+
497
+
498
+ </ul>
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+
509
+ <div id="instance_method_details" class="method_details_list">
510
+ <h2>Instance Method Details</h2>
511
+
512
+
513
+ <div class="method_details first">
514
+ <h3 class="signature first" id="associate-instance_method">
515
+
516
+ #<strong>associate</strong>(parent, child, association_name, association_type) &#x21d2; <tt>Object</tt>
517
+
518
+
519
+
520
+
521
+
522
+ </h3><div class="docstring">
523
+ <div class="discussion">
524
+
525
+ <p>When a has_many relationship, we need to avoid Activerecord implicitly
526
+ firing a query. Otherwise, simple assignment will do</p>
527
+
528
+
529
+ </div>
530
+ </div>
531
+ <div class="tags">
532
+
533
+
534
+ <p class="tag_title">See Also:</p>
535
+ <ul class="see">
536
+
537
+ <li><span class='object_link'><a href="Abstract.html#associate-instance_method" title="JsonapiCompliable::Adapters::Abstract#associate (method)">JsonapiCompliable::Adapters::Abstract#associate</a></span></li>
538
+
539
+ </ul>
540
+
541
+ </div><table class="source_code">
542
+ <tr>
543
+ <td>
544
+ <pre class="lines">
545
+
546
+
547
+ 71
548
+ 72
549
+ 73
550
+ 74
551
+ 75
552
+ 76
553
+ 77
554
+ 78</pre>
555
+ </td>
556
+ <td>
557
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 71</span>
558
+
559
+ <span class='kw'>def</span> <span class='id identifier rubyid_associate'>associate</span><span class='lparen'>(</span><span class='id identifier rubyid_parent'>parent</span><span class='comma'>,</span> <span class='id identifier rubyid_child'>child</span><span class='comma'>,</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='id identifier rubyid_association_type'>association_type</span><span class='rparen'>)</span>
560
+ <span class='kw'>if</span> <span class='id identifier rubyid_association_type'>association_type</span> <span class='op'>==</span> <span class='symbol'>:has_many</span>
561
+ <span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_loaded!'>loaded!</span>
562
+ <span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_add_to_target'>add_to_target</span><span class='lparen'>(</span><span class='id identifier rubyid_child'>child</span><span class='comma'>,</span> <span class='symbol'>:skip_callbacks</span><span class='rparen'>)</span>
563
+ <span class='kw'>else</span>
564
+ <span class='id identifier rubyid_child'>child</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_association_name'>association_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_parent'>parent</span><span class='rparen'>)</span>
565
+ <span class='kw'>end</span>
566
+ <span class='kw'>end</span></pre>
567
+ </td>
568
+ </tr>
569
+ </table>
570
+ </div>
571
+
572
+ <div class="method_details ">
573
+ <h3 class="signature " id="average-instance_method">
574
+
575
+ #<strong>average</strong>(scope, attr) &#x21d2; <tt>Float</tt>
576
+
577
+
578
+
579
+
580
+
581
+ </h3><div class="docstring">
582
+ <div class="discussion">
583
+
584
+ <p>Returns the average of the scope</p>
585
+
586
+
587
+ </div>
588
+ </div>
589
+ <div class="tags">
590
+
591
+ <div class="examples">
592
+ <p class="tag_title">Examples:</p>
593
+
594
+
595
+ <p class="example_title"><div class='inline'>
596
+ <p>ActiveRecord default</p>
597
+ </div></p>
598
+
599
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
600
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span>
601
+ <span class='kw'>end</span></code></pre>
602
+
603
+ </div>
604
+ <p class="tag_title">Parameters:</p>
605
+ <ul class="param">
606
+
607
+ <li>
608
+
609
+ <span class='name'>scope</span>
610
+
611
+
612
+ <span class='type'></span>
613
+
614
+
615
+
616
+ &mdash;
617
+ <div class='inline'>
618
+ <p>the scope object we are chaining</p>
619
+ </div>
620
+
621
+ </li>
622
+
623
+ <li>
624
+
625
+ <span class='name'>attr</span>
626
+
627
+
628
+ <span class='type'>(<tt>Symbol</tt>)</span>
629
+
630
+
631
+
632
+ &mdash;
633
+ <div class='inline'>
634
+ <p>corresponding stat attribute name</p>
635
+ </div>
636
+
637
+ </li>
638
+
639
+ </ul>
640
+
641
+ <p class="tag_title">Returns:</p>
642
+ <ul class="return">
643
+
644
+ <li>
645
+
646
+
647
+ <span class='type'>(<tt>Float</tt>)</span>
648
+
649
+
650
+
651
+ &mdash;
652
+ <div class='inline'>
653
+ <p>the average of the scope</p>
654
+ </div>
655
+
656
+ </li>
657
+
658
+ </ul>
659
+
660
+ </div><table class="source_code">
661
+ <tr>
662
+ <td>
663
+ <pre class="lines">
664
+
665
+
666
+ 29
667
+ 30
668
+ 31</pre>
669
+ </td>
670
+ <td>
671
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 29</span>
672
+
673
+ <span class='kw'>def</span> <span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
674
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_average'>average</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span>
675
+ <span class='kw'>end</span></pre>
676
+ </td>
677
+ </tr>
678
+ </table>
679
+ </div>
680
+
681
+ <div class="method_details ">
682
+ <h3 class="signature " id="count-instance_method">
683
+
684
+ #<strong>count</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
685
+
686
+
687
+
688
+
689
+
690
+ </h3><div class="docstring">
691
+ <div class="discussion">
692
+
693
+ <p>Returns the count of the scope</p>
694
+
695
+
696
+ </div>
697
+ </div>
698
+ <div class="tags">
699
+
700
+ <div class="examples">
701
+ <p class="tag_title">Examples:</p>
702
+
703
+
704
+ <p class="example_title"><div class='inline'>
705
+ <p>ActiveRecord default</p>
706
+ </div></p>
707
+
708
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
709
+ <span class='id identifier rubyid_column'>column</span> <span class='op'>=</span> <span class='id identifier rubyid_attr'>attr</span> <span class='op'>==</span> <span class='symbol'>:total</span> <span class='op'>?</span> <span class='symbol'>:all</span> <span class='op'>:</span> <span class='id identifier rubyid_attr'>attr</span>
710
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_column'>column</span><span class='rparen'>)</span>
711
+ <span class='kw'>end</span></code></pre>
712
+
713
+ </div>
714
+ <p class="tag_title">Parameters:</p>
715
+ <ul class="param">
716
+
717
+ <li>
718
+
719
+ <span class='name'>scope</span>
720
+
721
+
722
+ <span class='type'></span>
723
+
724
+
725
+
726
+ &mdash;
727
+ <div class='inline'>
728
+ <p>the scope object we are chaining</p>
729
+ </div>
730
+
731
+ </li>
732
+
733
+ <li>
734
+
735
+ <span class='name'>attr</span>
736
+
737
+
738
+ <span class='type'>(<tt>Symbol</tt>)</span>
739
+
740
+
741
+
742
+ &mdash;
743
+ <div class='inline'>
744
+ <p>corresponding stat attribute name</p>
745
+ </div>
746
+
747
+ </li>
748
+
749
+ </ul>
750
+
751
+ <p class="tag_title">Returns:</p>
752
+ <ul class="return">
753
+
754
+ <li>
755
+
756
+
757
+ <span class='type'>(<tt>Numeric</tt>)</span>
758
+
759
+
760
+
761
+ &mdash;
762
+ <div class='inline'>
763
+ <p>the count of the scope</p>
764
+ </div>
765
+
766
+ </li>
767
+
768
+ </ul>
769
+
770
+ </div><table class="source_code">
771
+ <tr>
772
+ <td>
773
+ <pre class="lines">
774
+
775
+
776
+ 23
777
+ 24
778
+ 25
779
+ 26</pre>
780
+ </td>
781
+ <td>
782
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 23</span>
783
+
784
+ <span class='kw'>def</span> <span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
785
+ <span class='id identifier rubyid_column'>column</span> <span class='op'>=</span> <span class='id identifier rubyid_attr'>attr</span> <span class='op'>==</span> <span class='symbol'>:total</span> <span class='op'>?</span> <span class='symbol'>:all</span> <span class='op'>:</span> <span class='id identifier rubyid_attr'>attr</span>
786
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_count'>count</span><span class='lparen'>(</span><span class='id identifier rubyid_column'>column</span><span class='rparen'>)</span>
787
+ <span class='kw'>end</span></pre>
788
+ </td>
789
+ </tr>
790
+ </table>
791
+ </div>
792
+
793
+ <div class="method_details ">
794
+ <h3 class="signature " id="create-instance_method">
795
+
796
+ #<strong>create</strong>(model_class, create_params) &#x21d2; <tt>Object</tt>
797
+
798
+
799
+
800
+
801
+
802
+ </h3><div class="docstring">
803
+ <div class="discussion">
804
+
805
+ <p>Returns the model instance just created</p>
806
+
807
+
808
+ </div>
809
+ </div>
810
+ <div class="tags">
811
+
812
+ <div class="examples">
813
+ <p class="tag_title">Examples:</p>
814
+
815
+
816
+ <p class="example_title"><div class='inline'>
817
+ <p>ActiveRecord default</p>
818
+ </div></p>
819
+
820
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
821
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
822
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
823
+ <span class='id identifier rubyid_instance'>instance</span>
824
+ <span class='kw'>end</span></code></pre>
825
+
826
+ </div>
827
+ <p class="tag_title">Parameters:</p>
828
+ <ul class="param">
829
+
830
+ <li>
831
+
832
+ <span class='name'>model_class</span>
833
+
834
+
835
+ <span class='type'>(<tt>Class</tt>)</span>
836
+
837
+
838
+
839
+ &mdash;
840
+ <div class='inline'>
841
+ <p>The configured model class (see Resource.model)</p>
842
+ </div>
843
+
844
+ </li>
845
+
846
+ <li>
847
+
848
+ <span class='name'>create_params</span>
849
+
850
+
851
+ <span class='type'>(<tt>Hash</tt>)</span>
852
+
853
+
854
+
855
+ &mdash;
856
+ <div class='inline'>
857
+ <p>Attributes + id</p>
858
+ </div>
859
+
860
+ </li>
861
+
862
+ </ul>
863
+
864
+ <p class="tag_title">Returns:</p>
865
+ <ul class="return">
866
+
867
+ <li>
868
+
869
+
870
+ <span class='type'></span>
871
+
872
+
873
+
874
+
875
+ <div class='inline'>
876
+ <p>the model instance just created</p>
877
+ </div>
878
+
879
+ </li>
880
+
881
+ </ul>
882
+
883
+ <p class="tag_title">See Also:</p>
884
+ <ul class="see">
885
+
886
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
887
+
888
+ </ul>
889
+
890
+ </div><table class="source_code">
891
+ <tr>
892
+ <td>
893
+ <pre class="lines">
894
+
895
+
896
+ 81
897
+ 82
898
+ 83
899
+ 84
900
+ 85</pre>
901
+ </td>
902
+ <td>
903
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 81</span>
904
+
905
+ <span class='kw'>def</span> <span class='id identifier rubyid_create'>create</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
906
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_create_params'>create_params</span><span class='rparen'>)</span>
907
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_save'>save</span>
908
+ <span class='id identifier rubyid_instance'>instance</span>
909
+ <span class='kw'>end</span></pre>
910
+ </td>
911
+ </tr>
912
+ </table>
913
+ </div>
914
+
915
+ <div class="method_details ">
916
+ <h3 class="signature " id="destroy-instance_method">
917
+
918
+ #<strong>destroy</strong>(model_class, id) &#x21d2; <tt>Object</tt>
919
+
920
+
921
+
922
+
923
+
924
+ </h3><div class="docstring">
925
+ <div class="discussion">
926
+
927
+ <p>Returns the model instance just destroyed</p>
928
+
929
+
930
+ </div>
931
+ </div>
932
+ <div class="tags">
933
+
934
+ <div class="examples">
935
+ <p class="tag_title">Examples:</p>
936
+
937
+
938
+ <p class="example_title"><div class='inline'>
939
+ <p>ActiveRecord default</p>
940
+ </div></p>
941
+
942
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_destroy'>destroy</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
943
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
944
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_destroy'>destroy</span>
945
+ <span class='id identifier rubyid_instance'>instance</span>
946
+ <span class='kw'>end</span></code></pre>
947
+
948
+ </div>
949
+ <p class="tag_title">Parameters:</p>
950
+ <ul class="param">
951
+
952
+ <li>
953
+
954
+ <span class='name'>model_class</span>
955
+
956
+
957
+ <span class='type'>(<tt>Class</tt>)</span>
958
+
959
+
960
+
961
+ &mdash;
962
+ <div class='inline'>
963
+ <p>The configured model class (see Resource.model)</p>
964
+ </div>
965
+
966
+ </li>
967
+
968
+ <li>
969
+
970
+ <span class='name'>id</span>
971
+
972
+
973
+ <span class='type'>(<tt>Integer</tt>)</span>
974
+
975
+
976
+
977
+ &mdash;
978
+ <div class='inline'>
979
+ <p>the id for this model</p>
980
+ </div>
981
+
982
+ </li>
983
+
984
+ </ul>
985
+
986
+ <p class="tag_title">Returns:</p>
987
+ <ul class="return">
988
+
989
+ <li>
990
+
991
+
992
+ <span class='type'></span>
993
+
994
+
995
+
996
+
997
+ <div class='inline'>
998
+ <p>the model instance just destroyed</p>
999
+ </div>
1000
+
1001
+ </li>
1002
+
1003
+ </ul>
1004
+
1005
+ <p class="tag_title">See Also:</p>
1006
+ <ul class="see">
1007
+
1008
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
1009
+
1010
+ </ul>
1011
+
1012
+ </div><table class="source_code">
1013
+ <tr>
1014
+ <td>
1015
+ <pre class="lines">
1016
+
1017
+
1018
+ 95
1019
+ 96
1020
+ 97
1021
+ 98
1022
+ 99</pre>
1023
+ </td>
1024
+ <td>
1025
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 95</span>
1026
+
1027
+ <span class='kw'>def</span> <span class='id identifier rubyid_destroy'>destroy</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1028
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_id'>id</span><span class='rparen'>)</span>
1029
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_destroy'>destroy</span>
1030
+ <span class='id identifier rubyid_instance'>instance</span>
1031
+ <span class='kw'>end</span></pre>
1032
+ </td>
1033
+ </tr>
1034
+ </table>
1035
+ </div>
1036
+
1037
+ <div class="method_details ">
1038
+ <h3 class="signature " id="filter-instance_method">
1039
+
1040
+ #<strong>filter</strong>(scope, attribute, value) &#x21d2; <tt>Object</tt>
1041
+
1042
+
1043
+
1044
+
1045
+
1046
+ </h3><div class="docstring">
1047
+ <div class="discussion">
1048
+
1049
+ <p>Returns the scope</p>
1050
+
1051
+
1052
+ </div>
1053
+ </div>
1054
+ <div class="tags">
1055
+
1056
+ <div class="examples">
1057
+ <p class="tag_title">Examples:</p>
1058
+
1059
+
1060
+ <p class="example_title"><div class='inline'>
1061
+ <p>ActiveRecord default</p>
1062
+ </div></p>
1063
+
1064
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_filter'>filter</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1065
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1066
+ <span class='kw'>end</span></code></pre>
1067
+
1068
+ </div>
1069
+ <p class="tag_title">Parameters:</p>
1070
+ <ul class="param">
1071
+
1072
+ <li>
1073
+
1074
+ <span class='name'>scope</span>
1075
+
1076
+
1077
+ <span class='type'></span>
1078
+
1079
+
1080
+
1081
+ &mdash;
1082
+ <div class='inline'>
1083
+ <p>The scope object we are chaining</p>
1084
+ </div>
1085
+
1086
+ </li>
1087
+
1088
+ <li>
1089
+
1090
+ <span class='name'>attribute</span>
1091
+
1092
+
1093
+ <span class='type'>(<tt>Symbol</tt>)</span>
1094
+
1095
+
1096
+
1097
+ &mdash;
1098
+ <div class='inline'>
1099
+ <p>The attribute name we are filtering</p>
1100
+ </div>
1101
+
1102
+ </li>
1103
+
1104
+ <li>
1105
+
1106
+ <span class='name'>value</span>
1107
+
1108
+
1109
+ <span class='type'></span>
1110
+
1111
+
1112
+
1113
+ &mdash;
1114
+ <div class='inline'>
1115
+ <p>The corresponding query parameter value</p>
1116
+ </div>
1117
+
1118
+ </li>
1119
+
1120
+ </ul>
1121
+
1122
+ <p class="tag_title">Returns:</p>
1123
+ <ul class="return">
1124
+
1125
+ <li>
1126
+
1127
+
1128
+ <span class='type'></span>
1129
+
1130
+
1131
+
1132
+
1133
+ <div class='inline'>
1134
+ <p>the scope</p>
1135
+ </div>
1136
+
1137
+ </li>
1138
+
1139
+ </ul>
1140
+
1141
+ </div><table class="source_code">
1142
+ <tr>
1143
+ <td>
1144
+ <pre class="lines">
1145
+
1146
+
1147
+ 8
1148
+ 9
1149
+ 10</pre>
1150
+ </td>
1151
+ <td>
1152
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 8</span>
1153
+
1154
+ <span class='kw'>def</span> <span class='id identifier rubyid_filter'>filter</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1155
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
1156
+ <span class='kw'>end</span></pre>
1157
+ </td>
1158
+ </tr>
1159
+ </table>
1160
+ </div>
1161
+
1162
+ <div class="method_details ">
1163
+ <h3 class="signature " id="maximum-instance_method">
1164
+
1165
+ #<strong>maximum</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
1166
+
1167
+
1168
+
1169
+
1170
+
1171
+ </h3><div class="docstring">
1172
+ <div class="discussion">
1173
+
1174
+ <p>Returns the maximum value of the scope</p>
1175
+
1176
+
1177
+ </div>
1178
+ </div>
1179
+ <div class="tags">
1180
+
1181
+ <div class="examples">
1182
+ <p class="tag_title">Examples:</p>
1183
+
1184
+
1185
+ <p class="example_title"><div class='inline'>
1186
+ <p>ActiveRecord default</p>
1187
+ </div></p>
1188
+
1189
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1190
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1191
+ <span class='kw'>end</span></code></pre>
1192
+
1193
+ </div>
1194
+ <p class="tag_title">Parameters:</p>
1195
+ <ul class="param">
1196
+
1197
+ <li>
1198
+
1199
+ <span class='name'>scope</span>
1200
+
1201
+
1202
+ <span class='type'></span>
1203
+
1204
+
1205
+
1206
+ &mdash;
1207
+ <div class='inline'>
1208
+ <p>the scope object we are chaining</p>
1209
+ </div>
1210
+
1211
+ </li>
1212
+
1213
+ <li>
1214
+
1215
+ <span class='name'>attr</span>
1216
+
1217
+
1218
+ <span class='type'>(<tt>Symbol</tt>)</span>
1219
+
1220
+
1221
+
1222
+ &mdash;
1223
+ <div class='inline'>
1224
+ <p>corresponding stat attribute name</p>
1225
+ </div>
1226
+
1227
+ </li>
1228
+
1229
+ </ul>
1230
+
1231
+ <p class="tag_title">Returns:</p>
1232
+ <ul class="return">
1233
+
1234
+ <li>
1235
+
1236
+
1237
+ <span class='type'>(<tt>Numeric</tt>)</span>
1238
+
1239
+
1240
+
1241
+ &mdash;
1242
+ <div class='inline'>
1243
+ <p>the maximum value of the scope</p>
1244
+ </div>
1245
+
1246
+ </li>
1247
+
1248
+ </ul>
1249
+
1250
+ </div><table class="source_code">
1251
+ <tr>
1252
+ <td>
1253
+ <pre class="lines">
1254
+
1255
+
1256
+ 39
1257
+ 40
1258
+ 41</pre>
1259
+ </td>
1260
+ <td>
1261
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 39</span>
1262
+
1263
+ <span class='kw'>def</span> <span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1264
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1265
+ <span class='kw'>end</span></pre>
1266
+ </td>
1267
+ </tr>
1268
+ </table>
1269
+ </div>
1270
+
1271
+ <div class="method_details ">
1272
+ <h3 class="signature " id="minimum-instance_method">
1273
+
1274
+ #<strong>minimum</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
1275
+
1276
+
1277
+
1278
+
1279
+
1280
+ </h3><div class="docstring">
1281
+ <div class="discussion">
1282
+
1283
+ <p>Returns the maximum value of the scope</p>
1284
+
1285
+
1286
+ </div>
1287
+ </div>
1288
+ <div class="tags">
1289
+
1290
+ <div class="examples">
1291
+ <p class="tag_title">Examples:</p>
1292
+
1293
+
1294
+ <p class="example_title"><div class='inline'>
1295
+ <p>ActiveRecord default</p>
1296
+ </div></p>
1297
+
1298
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1299
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_maximum'>maximum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1300
+ <span class='kw'>end</span></code></pre>
1301
+
1302
+ </div>
1303
+ <p class="tag_title">Parameters:</p>
1304
+ <ul class="param">
1305
+
1306
+ <li>
1307
+
1308
+ <span class='name'>scope</span>
1309
+
1310
+
1311
+ <span class='type'></span>
1312
+
1313
+
1314
+
1315
+ &mdash;
1316
+ <div class='inline'>
1317
+ <p>the scope object we are chaining</p>
1318
+ </div>
1319
+
1320
+ </li>
1321
+
1322
+ <li>
1323
+
1324
+ <span class='name'>attr</span>
1325
+
1326
+
1327
+ <span class='type'>(<tt>Symbol</tt>)</span>
1328
+
1329
+
1330
+
1331
+ &mdash;
1332
+ <div class='inline'>
1333
+ <p>corresponding stat attribute name</p>
1334
+ </div>
1335
+
1336
+ </li>
1337
+
1338
+ </ul>
1339
+
1340
+ <p class="tag_title">Returns:</p>
1341
+ <ul class="return">
1342
+
1343
+ <li>
1344
+
1345
+
1346
+ <span class='type'>(<tt>Numeric</tt>)</span>
1347
+
1348
+
1349
+
1350
+ &mdash;
1351
+ <div class='inline'>
1352
+ <p>the maximum value of the scope</p>
1353
+ </div>
1354
+
1355
+ </li>
1356
+
1357
+ </ul>
1358
+
1359
+ </div><table class="source_code">
1360
+ <tr>
1361
+ <td>
1362
+ <pre class="lines">
1363
+
1364
+
1365
+ 44
1366
+ 45
1367
+ 46</pre>
1368
+ </td>
1369
+ <td>
1370
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 44</span>
1371
+
1372
+ <span class='kw'>def</span> <span class='id identifier rubyid_minimum'>minimum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1373
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_minimum'>minimum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1374
+ <span class='kw'>end</span></pre>
1375
+ </td>
1376
+ </tr>
1377
+ </table>
1378
+ </div>
1379
+
1380
+ <div class="method_details ">
1381
+ <h3 class="signature " id="order-instance_method">
1382
+
1383
+ #<strong>order</strong>(scope, attribute, direction) &#x21d2; <tt>Object</tt>
1384
+
1385
+
1386
+
1387
+
1388
+
1389
+ </h3><div class="docstring">
1390
+ <div class="discussion">
1391
+
1392
+ <p>Returns the scope</p>
1393
+
1394
+
1395
+ </div>
1396
+ </div>
1397
+ <div class="tags">
1398
+
1399
+ <div class="examples">
1400
+ <p class="tag_title">Examples:</p>
1401
+
1402
+
1403
+ <p class="example_title"><div class='inline'>
1404
+ <p>ActiveRecord default</p>
1405
+ </div></p>
1406
+
1407
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1408
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1409
+ <span class='kw'>end</span></code></pre>
1410
+
1411
+ </div>
1412
+ <p class="tag_title">Parameters:</p>
1413
+ <ul class="param">
1414
+
1415
+ <li>
1416
+
1417
+ <span class='name'>scope</span>
1418
+
1419
+
1420
+ <span class='type'></span>
1421
+
1422
+
1423
+
1424
+ &mdash;
1425
+ <div class='inline'>
1426
+ <p>The scope object we are chaining</p>
1427
+ </div>
1428
+
1429
+ </li>
1430
+
1431
+ <li>
1432
+
1433
+ <span class='name'>attribute</span>
1434
+
1435
+
1436
+ <span class='type'>(<tt>Symbol</tt>)</span>
1437
+
1438
+
1439
+
1440
+ &mdash;
1441
+ <div class='inline'>
1442
+ <p>The attribute name we are sorting</p>
1443
+ </div>
1444
+
1445
+ </li>
1446
+
1447
+ <li>
1448
+
1449
+ <span class='name'>direction</span>
1450
+
1451
+
1452
+ <span class='type'>(<tt>Symbol</tt>)</span>
1453
+
1454
+
1455
+
1456
+ &mdash;
1457
+ <div class='inline'>
1458
+ <p>The direction we are sorting (asc/desc)</p>
1459
+ </div>
1460
+
1461
+ </li>
1462
+
1463
+ </ul>
1464
+
1465
+ <p class="tag_title">Returns:</p>
1466
+ <ul class="return">
1467
+
1468
+ <li>
1469
+
1470
+
1471
+ <span class='type'></span>
1472
+
1473
+
1474
+
1475
+
1476
+ <div class='inline'>
1477
+ <p>the scope</p>
1478
+ </div>
1479
+
1480
+ </li>
1481
+
1482
+ </ul>
1483
+
1484
+ </div><table class="source_code">
1485
+ <tr>
1486
+ <td>
1487
+ <pre class="lines">
1488
+
1489
+
1490
+ 13
1491
+ 14
1492
+ 15</pre>
1493
+ </td>
1494
+ <td>
1495
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 13</span>
1496
+
1497
+ <span class='kw'>def</span> <span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1498
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_direction'>direction</span><span class='rparen'>)</span>
1499
+ <span class='kw'>end</span></pre>
1500
+ </td>
1501
+ </tr>
1502
+ </table>
1503
+ </div>
1504
+
1505
+ <div class="method_details ">
1506
+ <h3 class="signature " id="paginate-instance_method">
1507
+
1508
+ #<strong>paginate</strong>(scope, current_page, per_page) &#x21d2; <tt>Object</tt>
1509
+
1510
+
1511
+
1512
+
1513
+
1514
+ </h3><div class="docstring">
1515
+ <div class="discussion">
1516
+
1517
+ <p>Returns the scope</p>
1518
+
1519
+
1520
+ </div>
1521
+ </div>
1522
+ <div class="tags">
1523
+
1524
+ <div class="examples">
1525
+ <p class="tag_title">Examples:</p>
1526
+
1527
+
1528
+ <p class="example_title"><div class='inline'>
1529
+ <p>ActiveRecord default</p>
1530
+ </div></p>
1531
+
1532
+ <pre class="example code"><code><span class='comment'># via kaminari gem
1533
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_paginate'>paginate</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_current_page'>current_page</span><span class='comma'>,</span> <span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1534
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='lparen'>(</span><span class='id identifier rubyid_current_page'>current_page</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_per'>per</span><span class='lparen'>(</span><span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1535
+ <span class='kw'>end</span></code></pre>
1536
+
1537
+ </div>
1538
+ <p class="tag_title">Parameters:</p>
1539
+ <ul class="param">
1540
+
1541
+ <li>
1542
+
1543
+ <span class='name'>scope</span>
1544
+
1545
+
1546
+ <span class='type'></span>
1547
+
1548
+
1549
+
1550
+ &mdash;
1551
+ <div class='inline'>
1552
+ <p>The scope object we are chaining</p>
1553
+ </div>
1554
+
1555
+ </li>
1556
+
1557
+ <li>
1558
+
1559
+ <span class='name'>current_page</span>
1560
+
1561
+
1562
+ <span class='type'>(<tt>Integer</tt>)</span>
1563
+
1564
+
1565
+
1566
+ &mdash;
1567
+ <div class='inline'>
1568
+ <p>The current page number</p>
1569
+ </div>
1570
+
1571
+ </li>
1572
+
1573
+ <li>
1574
+
1575
+ <span class='name'>per_page</span>
1576
+
1577
+
1578
+ <span class='type'>(<tt>Integer</tt>)</span>
1579
+
1580
+
1581
+
1582
+ &mdash;
1583
+ <div class='inline'>
1584
+ <p>The number of results per page</p>
1585
+ </div>
1586
+
1587
+ </li>
1588
+
1589
+ </ul>
1590
+
1591
+ <p class="tag_title">Returns:</p>
1592
+ <ul class="return">
1593
+
1594
+ <li>
1595
+
1596
+
1597
+ <span class='type'></span>
1598
+
1599
+
1600
+
1601
+
1602
+ <div class='inline'>
1603
+ <p>the scope</p>
1604
+ </div>
1605
+
1606
+ </li>
1607
+
1608
+ </ul>
1609
+
1610
+ </div><table class="source_code">
1611
+ <tr>
1612
+ <td>
1613
+ <pre class="lines">
1614
+
1615
+
1616
+ 18
1617
+ 19
1618
+ 20</pre>
1619
+ </td>
1620
+ <td>
1621
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 18</span>
1622
+
1623
+ <span class='kw'>def</span> <span class='id identifier rubyid_paginate'>paginate</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_current_page'>current_page</span><span class='comma'>,</span> <span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1624
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_page'>page</span><span class='lparen'>(</span><span class='id identifier rubyid_current_page'>current_page</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_per'>per</span><span class='lparen'>(</span><span class='id identifier rubyid_per_page'>per_page</span><span class='rparen'>)</span>
1625
+ <span class='kw'>end</span></pre>
1626
+ </td>
1627
+ </tr>
1628
+ </table>
1629
+ </div>
1630
+
1631
+ <div class="method_details ">
1632
+ <h3 class="signature " id="resolve-instance_method">
1633
+
1634
+ #<strong>resolve</strong>(scope) &#x21d2; <tt>Object</tt>
1635
+
1636
+
1637
+
1638
+
1639
+
1640
+ </h3><div class="docstring">
1641
+ <div class="discussion">
1642
+
1643
+ <p>Resolve the scope. This is where you&#39;d actually fire SQL, actually make
1644
+ an HTTP call, etc.</p>
1645
+
1646
+
1647
+ </div>
1648
+ </div>
1649
+ <div class="tags">
1650
+
1651
+ <div class="examples">
1652
+ <p class="tag_title">Examples:</p>
1653
+
1654
+
1655
+ <p class="example_title"><div class='inline'>
1656
+ <p>ActiveRecordDefault</p>
1657
+ </div></p>
1658
+
1659
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1660
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
1661
+ <span class='kw'>end</span></code></pre>
1662
+
1663
+
1664
+ <p class="example_title"><div class='inline'>
1665
+ <p>Suggested Customization</p>
1666
+ </div></p>
1667
+
1668
+ <pre class="example code"><code><span class='comment'># When making a service call, we suggest this abstraction
1669
+ </span><span class='comment'># &#39;scope&#39; here is a hash
1670
+ </span><span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1671
+ <span class='comment'># The implementation of .where can be whatever you want
1672
+ </span> <span class='const'>SomeModelClass</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1673
+ <span class='kw'>end</span></code></pre>
1674
+
1675
+ </div>
1676
+ <p class="tag_title">Parameters:</p>
1677
+ <ul class="param">
1678
+
1679
+ <li>
1680
+
1681
+ <span class='name'>scope</span>
1682
+
1683
+
1684
+ <span class='type'></span>
1685
+
1686
+
1687
+
1688
+ &mdash;
1689
+ <div class='inline'>
1690
+ <p>The scope object to resolve</p>
1691
+ </div>
1692
+
1693
+ </li>
1694
+
1695
+ </ul>
1696
+
1697
+ <p class="tag_title">Returns:</p>
1698
+ <ul class="return">
1699
+
1700
+ <li>
1701
+
1702
+
1703
+ <span class='type'></span>
1704
+
1705
+
1706
+
1707
+
1708
+ <div class='inline'>
1709
+ <p>an array of Model instances</p>
1710
+ </div>
1711
+
1712
+ </li>
1713
+
1714
+ </ul>
1715
+
1716
+ <p class="tag_title">See Also:</p>
1717
+ <ul class="see">
1718
+
1719
+ <li><span class='object_link'><a href="#resolve-instance_method" title="JsonapiCompliable::Adapters::ActiveRecord#resolve (method)">#resolve</a></span></li>
1720
+
1721
+ </ul>
1722
+
1723
+ </div><table class="source_code">
1724
+ <tr>
1725
+ <td>
1726
+ <pre class="lines">
1727
+
1728
+
1729
+ 49
1730
+ 50
1731
+ 51</pre>
1732
+ </td>
1733
+ <td>
1734
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 49</span>
1735
+
1736
+ <span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span>
1737
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_to_a'>to_a</span>
1738
+ <span class='kw'>end</span></pre>
1739
+ </td>
1740
+ </tr>
1741
+ </table>
1742
+ </div>
1743
+
1744
+ <div class="method_details ">
1745
+ <h3 class="signature " id="sideloading_module-instance_method">
1746
+
1747
+ #<strong>sideloading_module</strong> &#x21d2; <tt>Object</tt>
1748
+
1749
+
1750
+
1751
+
1752
+
1753
+ </h3><div class="docstring">
1754
+ <div class="discussion">
1755
+
1756
+ <p>This module gets mixed in to Sideload classes This is where you define
1757
+ methods like has_many, belongs_to etc that wrap the lower-level
1758
+ Sideload#allow_sideload</p>
1759
+
1760
+
1761
+ </div>
1762
+ </div>
1763
+ <div class="tags">
1764
+
1765
+ <p class="tag_title">Returns:</p>
1766
+ <ul class="return">
1767
+
1768
+ <li>
1769
+
1770
+
1771
+ <span class='type'></span>
1772
+
1773
+
1774
+
1775
+
1776
+ <div class='inline'>
1777
+ <p>the module to mix in</p>
1778
+ </div>
1779
+
1780
+ </li>
1781
+
1782
+ </ul>
1783
+
1784
+ <p class="tag_title">See Also:</p>
1785
+ <ul class="see">
1786
+
1787
+ <li>Resource#allow_sideload</li>
1788
+
1789
+ <li><span class='object_link'><a href="../Sideload.html#allow_sideload-instance_method" title="JsonapiCompliable::Sideload#allow_sideload (method)">Sideload#allow_sideload</a></span></li>
1790
+
1791
+ <li><span class='object_link'><a href="#sideloading_module-instance_method" title="JsonapiCompliable::Adapters::ActiveRecord#sideloading_module (method)">#sideloading_module</a></span></li>
1792
+
1793
+ <li><span class='object_link'><a href="ActiveRecordSideloading.html" title="JsonapiCompliable::Adapters::ActiveRecordSideloading (module)">JsonapiCompliable::Adapters::ActiveRecordSideloading</a></span></li>
1794
+
1795
+ </ul>
1796
+
1797
+ </div><table class="source_code">
1798
+ <tr>
1799
+ <td>
1800
+ <pre class="lines">
1801
+
1802
+
1803
+ 64
1804
+ 65
1805
+ 66</pre>
1806
+ </td>
1807
+ <td>
1808
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 64</span>
1809
+
1810
+ <span class='kw'>def</span> <span class='id identifier rubyid_sideloading_module'>sideloading_module</span>
1811
+ <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="ActiveRecordSideloading.html" title="JsonapiCompliable::Adapters::ActiveRecordSideloading (module)">ActiveRecordSideloading</a></span></span>
1812
+ <span class='kw'>end</span></pre>
1813
+ </td>
1814
+ </tr>
1815
+ </table>
1816
+ </div>
1817
+
1818
+ <div class="method_details ">
1819
+ <h3 class="signature " id="sum-instance_method">
1820
+
1821
+ #<strong>sum</strong>(scope, attr) &#x21d2; <tt>Numeric</tt>
1822
+
1823
+
1824
+
1825
+
1826
+
1827
+ </h3><div class="docstring">
1828
+ <div class="discussion">
1829
+
1830
+ <p>Returns the sum of the scope</p>
1831
+
1832
+
1833
+ </div>
1834
+ </div>
1835
+ <div class="tags">
1836
+
1837
+ <div class="examples">
1838
+ <p class="tag_title">Examples:</p>
1839
+
1840
+
1841
+ <p class="example_title"><div class='inline'>
1842
+ <p>ActiveRecord default</p>
1843
+ </div></p>
1844
+
1845
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1846
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1847
+ <span class='kw'>end</span></code></pre>
1848
+
1849
+ </div>
1850
+ <p class="tag_title">Parameters:</p>
1851
+ <ul class="param">
1852
+
1853
+ <li>
1854
+
1855
+ <span class='name'>scope</span>
1856
+
1857
+
1858
+ <span class='type'></span>
1859
+
1860
+
1861
+
1862
+ &mdash;
1863
+ <div class='inline'>
1864
+ <p>the scope object we are chaining</p>
1865
+ </div>
1866
+
1867
+ </li>
1868
+
1869
+ <li>
1870
+
1871
+ <span class='name'>attr</span>
1872
+
1873
+
1874
+ <span class='type'>(<tt>Symbol</tt>)</span>
1875
+
1876
+
1877
+
1878
+ &mdash;
1879
+ <div class='inline'>
1880
+ <p>corresponding stat attribute name</p>
1881
+ </div>
1882
+
1883
+ </li>
1884
+
1885
+ </ul>
1886
+
1887
+ <p class="tag_title">Returns:</p>
1888
+ <ul class="return">
1889
+
1890
+ <li>
1891
+
1892
+
1893
+ <span class='type'>(<tt>Numeric</tt>)</span>
1894
+
1895
+
1896
+
1897
+ &mdash;
1898
+ <div class='inline'>
1899
+ <p>the sum of the scope</p>
1900
+ </div>
1901
+
1902
+ </li>
1903
+
1904
+ </ul>
1905
+
1906
+ </div><table class="source_code">
1907
+ <tr>
1908
+ <td>
1909
+ <pre class="lines">
1910
+
1911
+
1912
+ 34
1913
+ 35
1914
+ 36</pre>
1915
+ </td>
1916
+ <td>
1917
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 34</span>
1918
+
1919
+ <span class='kw'>def</span> <span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1920
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='id identifier rubyid_attr'>attr</span><span class='rparen'>)</span>
1921
+ <span class='kw'>end</span></pre>
1922
+ </td>
1923
+ </tr>
1924
+ </table>
1925
+ </div>
1926
+
1927
+ <div class="method_details ">
1928
+ <h3 class="signature " id="transaction-instance_method">
1929
+
1930
+ #<strong>transaction</strong>(model_class) &#x21d2; <tt>Object</tt>
1931
+
1932
+
1933
+
1934
+
1935
+
1936
+ </h3><div class="docstring">
1937
+ <div class="discussion">
1938
+
1939
+ <p>Run this write request within an ActiveRecord transaction</p>
1940
+
1941
+
1942
+ </div>
1943
+ </div>
1944
+ <div class="tags">
1945
+ <p class="tag_title">Parameters:</p>
1946
+ <ul class="param">
1947
+
1948
+ <li>
1949
+
1950
+ <span class='name'>model_class</span>
1951
+
1952
+
1953
+ <span class='type'>(<tt>Class</tt>)</span>
1954
+
1955
+
1956
+
1957
+ &mdash;
1958
+ <div class='inline'>
1959
+ <p>The ActiveRecord class we are saving</p>
1960
+ </div>
1961
+
1962
+ </li>
1963
+
1964
+ </ul>
1965
+
1966
+ <p class="tag_title">Returns:</p>
1967
+ <ul class="return">
1968
+
1969
+ <li>
1970
+
1971
+
1972
+ <span class='type'></span>
1973
+
1974
+
1975
+
1976
+
1977
+ <div class='inline'>
1978
+ <p>Result of yield</p>
1979
+ </div>
1980
+
1981
+ </li>
1982
+
1983
+ </ul>
1984
+
1985
+ <p class="tag_title">See Also:</p>
1986
+ <ul class="see">
1987
+
1988
+ <li><span class='object_link'><a href="Abstract.html#transaction-instance_method" title="JsonapiCompliable::Adapters::Abstract#transaction (method)">JsonapiCompliable::Adapters::Abstract#transaction</a></span></li>
1989
+
1990
+ </ul>
1991
+
1992
+ </div><table class="source_code">
1993
+ <tr>
1994
+ <td>
1995
+ <pre class="lines">
1996
+
1997
+
1998
+ 57
1999
+ 58
2000
+ 59
2001
+ 60
2002
+ 61</pre>
2003
+ </td>
2004
+ <td>
2005
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 57</span>
2006
+
2007
+ <span class='kw'>def</span> <span class='id identifier rubyid_transaction'>transaction</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='rparen'>)</span>
2008
+ <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_transaction'>transaction</span> <span class='kw'>do</span>
2009
+ <span class='kw'>yield</span>
2010
+ <span class='kw'>end</span>
2011
+ <span class='kw'>end</span></pre>
2012
+ </td>
2013
+ </tr>
2014
+ </table>
2015
+ </div>
2016
+
2017
+ <div class="method_details ">
2018
+ <h3 class="signature " id="update-instance_method">
2019
+
2020
+ #<strong>update</strong>(model_class, update_params) &#x21d2; <tt>Object</tt>
2021
+
2022
+
2023
+
2024
+
2025
+
2026
+ </h3><div class="docstring">
2027
+ <div class="discussion">
2028
+
2029
+ <p>Returns the model instance just created</p>
2030
+
2031
+
2032
+ </div>
2033
+ </div>
2034
+ <div class="tags">
2035
+
2036
+ <div class="examples">
2037
+ <p class="tag_title">Examples:</p>
2038
+
2039
+
2040
+ <p class="example_title"><div class='inline'>
2041
+ <p>ActiveRecord default</p>
2042
+ </div></p>
2043
+
2044
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2045
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_update_params'>update_params</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='rparen'>)</span>
2046
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_update_attributes'>update_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2047
+ <span class='id identifier rubyid_instance'>instance</span>
2048
+ <span class='kw'>end</span></code></pre>
2049
+
2050
+ </div>
2051
+ <p class="tag_title">Parameters:</p>
2052
+ <ul class="param">
2053
+
2054
+ <li>
2055
+
2056
+ <span class='name'>model_class</span>
2057
+
2058
+
2059
+ <span class='type'>(<tt>Class</tt>)</span>
2060
+
2061
+
2062
+
2063
+ &mdash;
2064
+ <div class='inline'>
2065
+ <p>The configured model class (see Resource.model)</p>
2066
+ </div>
2067
+
2068
+ </li>
2069
+
2070
+ <li>
2071
+
2072
+ <span class='name'>update_params</span>
2073
+
2074
+
2075
+ <span class='type'>(<tt>Hash</tt>)</span>
2076
+
2077
+
2078
+
2079
+ &mdash;
2080
+ <div class='inline'>
2081
+ <p>Attributes + id</p>
2082
+ </div>
2083
+
2084
+ </li>
2085
+
2086
+ </ul>
2087
+
2088
+ <p class="tag_title">Returns:</p>
2089
+ <ul class="return">
2090
+
2091
+ <li>
2092
+
2093
+
2094
+ <span class='type'></span>
2095
+
2096
+
2097
+
2098
+
2099
+ <div class='inline'>
2100
+ <p>the model instance just created</p>
2101
+ </div>
2102
+
2103
+ </li>
2104
+
2105
+ </ul>
2106
+
2107
+ <p class="tag_title">See Also:</p>
2108
+ <ul class="see">
2109
+
2110
+ <li><span class='object_link'><a href="../Resource.html#model-class_method" title="JsonapiCompliable::Resource.model (method)">Resource.model</a></span></li>
2111
+
2112
+ </ul>
2113
+
2114
+ </div><table class="source_code">
2115
+ <tr>
2116
+ <td>
2117
+ <pre class="lines">
2118
+
2119
+
2120
+ 88
2121
+ 89
2122
+ 90
2123
+ 91
2124
+ 92</pre>
2125
+ </td>
2126
+ <td>
2127
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record.rb', line 88</span>
2128
+
2129
+ <span class='kw'>def</span> <span class='id identifier rubyid_update'>update</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2130
+ <span class='id identifier rubyid_instance'>instance</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_update_params'>update_params</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='rparen'>)</span>
2131
+ <span class='id identifier rubyid_instance'>instance</span><span class='period'>.</span><span class='id identifier rubyid_update_attributes'>update_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_update_params'>update_params</span><span class='rparen'>)</span>
2132
+ <span class='id identifier rubyid_instance'>instance</span>
2133
+ <span class='kw'>end</span></pre>
2134
+ </td>
2135
+ </tr>
2136
+ </table>
2137
+ </div>
2138
+
2139
+ </div>
2140
+
2141
+ </div>
2142
+
2143
+ <div id="footer">
2144
+ Generated on Fri May 5 15:53:23 2017 by
2145
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2146
+ 0.9.9 (ruby-2.3.0).
2147
+ </div>
2148
+
2149
+ </div>
2150
+ </body>
2151
+ </html>