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,703 @@
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::Scope
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::Scope";
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 (S)</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">Scope</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::Scope
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+ <dl>
70
+ <dt>Inherits:</dt>
71
+ <dd>
72
+ <span class="inheritName">Object</span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next">JsonapiCompliable::Scope</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/jsonapi_compliable/scope.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>A Scope wraps an underlying object. It modifies that object using the
106
+ corresponding Resource and Query, and how to resolve that underlying object
107
+ scope.</p>
108
+
109
+
110
+ </div>
111
+ </div>
112
+ <div class="tags">
113
+
114
+ <div class="examples">
115
+ <p class="tag_title">Examples:</p>
116
+
117
+
118
+ <p class="example_title"><div class='inline'>
119
+ <p>Basic Controller usage</p>
120
+ </div></p>
121
+
122
+ <pre class="example code"><code><span class='kw'>def</span> <span class='id identifier rubyid_index'>index</span>
123
+ <span class='id identifier rubyid_base'>base</span> <span class='op'>=</span> <span class='const'>Post</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span>
124
+ <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_base'>base</span><span class='rparen'>)</span>
125
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span> <span class='op'>==</span> <span class='id identifier rubyid_base'>base</span> <span class='comment'># =&gt; true
126
+ </span> <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span> <span class='op'>=</span> <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_where'>where</span><span class='lparen'>(</span><span class='label'>active:</span> <span class='kw'>true</span><span class='rparen'>)</span>
127
+
128
+ <span class='comment'># actually fires sql
129
+ </span> <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span> <span class='comment'>#=&gt; [#&lt;Post ...&gt;, #&lt;Post ...&gt;, etc]
130
+ </span><span class='kw'>end</span></code></pre>
131
+
132
+ </div>
133
+
134
+
135
+ </div>
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <h2>
144
+ Instance Method Summary
145
+ <small><a href="#" class="summary_toggle">collapse</a></small>
146
+ </h2>
147
+
148
+ <ul class="summary">
149
+
150
+ <li class="public ">
151
+ <span class="summary_signature">
152
+
153
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(object, resource, query, opts = {}) &#x21d2; Scope </a>
154
+
155
+
156
+
157
+ </span>
158
+
159
+
160
+ <span class="note title constructor">constructor</span>
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'>
170
+ <p>A new instance of Scope.</p>
171
+ </div></span>
172
+
173
+ </li>
174
+
175
+
176
+ <li class="public ">
177
+ <span class="summary_signature">
178
+
179
+ <a href="#query_hash-instance_method" title="#query_hash (instance method)">#<strong>query_hash</strong> &#x21d2; Object </a>
180
+
181
+
182
+
183
+ </span>
184
+
185
+
186
+
187
+
188
+
189
+
190
+ <span class="private note title">private</span>
191
+
192
+
193
+ <span class="summary_desc"><div class='inline'>
194
+ <p>The slice of Query#to_hash for the current namespace.</p>
195
+ </div></span>
196
+
197
+ </li>
198
+
199
+
200
+ <li class="public ">
201
+ <span class="summary_signature">
202
+
203
+ <a href="#resolve-instance_method" title="#resolve (instance method)">#<strong>resolve</strong> &#x21d2; Array </a>
204
+
205
+
206
+
207
+ </span>
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ <span class="summary_desc"><div class='inline'>
218
+ <p>Resolve the scope.</p>
219
+ </div></span>
220
+
221
+ </li>
222
+
223
+
224
+ <li class="public ">
225
+ <span class="summary_signature">
226
+
227
+ <a href="#resolve_stats-instance_method" title="#resolve_stats (instance method)">#<strong>resolve_stats</strong> &#x21d2; Hash </a>
228
+
229
+
230
+
231
+ </span>
232
+
233
+
234
+
235
+
236
+
237
+
238
+ <span class="private note title">private</span>
239
+
240
+
241
+ <span class="summary_desc"><div class='inline'>
242
+ <p>Resolve the requested stats.</p>
243
+ </div></span>
244
+
245
+ </li>
246
+
247
+
248
+ </ul>
249
+
250
+
251
+ <div id="constructor_details" class="method_details_list">
252
+ <h2>Constructor Details</h2>
253
+
254
+ <div class="method_details first">
255
+ <h3 class="signature first" id="initialize-instance_method">
256
+
257
+ #<strong>initialize</strong>(object, resource, query, opts = {}) &#x21d2; <tt><span class='object_link'><a href="" title="JsonapiCompliable::Scope (class)">Scope</a></span></tt>
258
+
259
+
260
+
261
+
262
+
263
+ </h3><div class="docstring">
264
+ <div class="discussion">
265
+
266
+ <p>Returns a new instance of Scope</p>
267
+
268
+
269
+ </div>
270
+ </div>
271
+ <div class="tags">
272
+ <p class="tag_title">Parameters:</p>
273
+ <ul class="param">
274
+
275
+ <li>
276
+
277
+ <span class='name'>object</span>
278
+
279
+
280
+ <span class='type'></span>
281
+
282
+
283
+
284
+ &mdash;
285
+ <div class='inline'><ul><li>
286
+ <p>The underlying, chainable base scope object</p>
287
+ </li></ul>
288
+ </div>
289
+
290
+ </li>
291
+
292
+ <li>
293
+
294
+ <span class='name'>resource</span>
295
+
296
+
297
+ <span class='type'></span>
298
+
299
+
300
+
301
+ &mdash;
302
+ <div class='inline'><ul><li>
303
+ <p>The Resource that will process the object</p>
304
+ </li></ul>
305
+ </div>
306
+
307
+ </li>
308
+
309
+ <li>
310
+
311
+ <span class='name'>query</span>
312
+
313
+
314
+ <span class='type'></span>
315
+
316
+
317
+
318
+ &mdash;
319
+ <div class='inline'><ul><li>
320
+ <p>The Query object for the current request</p>
321
+ </li></ul>
322
+ </div>
323
+
324
+ </li>
325
+
326
+ <li>
327
+
328
+ <span class='name'>opts</span>
329
+
330
+
331
+ <span class='type'>(<tt>Hash</tt>)</span>
332
+
333
+
334
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
335
+
336
+
337
+ &mdash;
338
+ <div class='inline'>
339
+ <p>Options to configure the Scope</p>
340
+ </div>
341
+
342
+ </li>
343
+
344
+ </ul>
345
+
346
+
347
+
348
+
349
+
350
+
351
+
352
+
353
+
354
+
355
+ <p class="tag_title">Options Hash (<tt>opts</tt>):</p>
356
+ <ul class="option">
357
+
358
+ <li>
359
+ <span class="name">:namespace</span>
360
+ <span class="type">(<tt>String</tt>)</span>
361
+ <span class="default">
362
+
363
+ </span>
364
+
365
+ &mdash; <div class='inline'>
366
+ <p>The nested relationship name</p>
367
+ </div>
368
+
369
+ </li>
370
+
371
+ <li>
372
+ <span class="name">:filter</span>
373
+ <span class="type">(<tt>Boolean</tt>)</span>
374
+ <span class="default">
375
+
376
+ </span>
377
+
378
+ &mdash; <div class='inline'>
379
+ <p>Opt-out of filter scoping</p>
380
+ </div>
381
+
382
+ </li>
383
+
384
+ <li>
385
+ <span class="name">:extra_fields</span>
386
+ <span class="type">(<tt>Boolean</tt>)</span>
387
+ <span class="default">
388
+
389
+ </span>
390
+
391
+ &mdash; <div class='inline'>
392
+ <p>Opt-out of extra_fields scoping</p>
393
+ </div>
394
+
395
+ </li>
396
+
397
+ <li>
398
+ <span class="name">:sort</span>
399
+ <span class="type">(<tt>Boolean</tt>)</span>
400
+ <span class="default">
401
+
402
+ </span>
403
+
404
+ &mdash; <div class='inline'>
405
+ <p>Opt-out of sort scoping</p>
406
+ </div>
407
+
408
+ </li>
409
+
410
+ <li>
411
+ <span class="name">:pagination</span>
412
+ <span class="type">(<tt>Boolean</tt>)</span>
413
+ <span class="default">
414
+
415
+ </span>
416
+
417
+ &mdash; <div class='inline'>
418
+ <p>Opt-out of pagination scoping</p>
419
+ </div>
420
+
421
+ </li>
422
+
423
+ <li>
424
+ <span class="name">:default_paginate</span>
425
+ <span class="type">(<tt>Boolean</tt>)</span>
426
+ <span class="default">
427
+
428
+ </span>
429
+
430
+ &mdash; <div class='inline'>
431
+ <p>Opt-out of default pagination when not specified in request</p>
432
+ </div>
433
+
434
+ </li>
435
+
436
+ </ul>
437
+
438
+
439
+
440
+ </div><table class="source_code">
441
+ <tr>
442
+ <td>
443
+ <pre class="lines">
444
+
445
+
446
+ 27
447
+ 28
448
+ 29
449
+ 30
450
+ 31
451
+ 32
452
+ 33
453
+ 34
454
+ 35
455
+ 36
456
+ 37
457
+ 38
458
+ 39</pre>
459
+ </td>
460
+ <td>
461
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scope.rb', line 27</span>
462
+
463
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_object'>object</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</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='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
464
+ <span class='ivar'>@object</span> <span class='op'>=</span> <span class='id identifier rubyid_object'>object</span>
465
+ <span class='ivar'>@resource</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span>
466
+ <span class='ivar'>@query</span> <span class='op'>=</span> <span class='id identifier rubyid_query'>query</span>
467
+
468
+ <span class='comment'># Namespace for the &#39;outer&#39; or &#39;main&#39; resource is its type
469
+ </span> <span class='comment'># For its relationships, its the relationship name
470
+ </span> <span class='comment'># IOW when hitting /states, it&#39;s resource type &#39;states&#39;
471
+ </span> <span class='comment'># when hitting /authors?include=state its &#39;state&#39;
472
+ </span> <span class='ivar'>@namespace</span> <span class='op'>=</span> <span class='id identifier rubyid_opts'>opts</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:namespace</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span>
473
+
474
+ <span class='id identifier rubyid_apply_scoping'>apply_scoping</span><span class='lparen'>(</span><span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
475
+ <span class='kw'>end</span></pre>
476
+ </td>
477
+ </tr>
478
+ </table>
479
+ </div>
480
+
481
+ </div>
482
+
483
+
484
+ <div id="instance_method_details" class="method_details_list">
485
+ <h2>Instance Method Details</h2>
486
+
487
+
488
+ <div class="method_details first">
489
+ <h3 class="signature first" id="query_hash-instance_method">
490
+
491
+ #<strong>query_hash</strong> &#x21d2; <tt>Object</tt>
492
+
493
+
494
+
495
+
496
+
497
+ </h3><div class="docstring">
498
+ <div class="discussion">
499
+ <p class="note private">
500
+ <strong>This method is part of a private API.</strong>
501
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
502
+ </p>
503
+
504
+ <p>The slice of Query#to_hash for the current namespace</p>
505
+
506
+
507
+ </div>
508
+ </div>
509
+ <div class="tags">
510
+
511
+
512
+ <p class="tag_title">See Also:</p>
513
+ <ul class="see">
514
+
515
+ <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>
516
+
517
+ </ul>
518
+
519
+ </div><table class="source_code">
520
+ <tr>
521
+ <td>
522
+ <pre class="lines">
523
+
524
+
525
+ 73
526
+ 74
527
+ 75</pre>
528
+ </td>
529
+ <td>
530
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scope.rb', line 73</span>
531
+
532
+ <span class='kw'>def</span> <span class='id identifier rubyid_query_hash'>query_hash</span>
533
+ <span class='ivar'>@query_hash</span> <span class='op'>||=</span> <span class='ivar'>@query</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span><span class='lbracket'>[</span><span class='ivar'>@namespace</span><span class='rbracket'>]</span>
534
+ <span class='kw'>end</span></pre>
535
+ </td>
536
+ </tr>
537
+ </table>
538
+ </div>
539
+
540
+ <div class="method_details ">
541
+ <h3 class="signature " id="resolve-instance_method">
542
+
543
+ #<strong>resolve</strong> &#x21d2; <tt>Array</tt>
544
+
545
+
546
+
547
+
548
+
549
+ </h3><div class="docstring">
550
+ <div class="discussion">
551
+
552
+ <p>Resolve the scope. This is where SQL is actually fired, an HTTP request is
553
+ actually made, etc.</p>
554
+
555
+ <p>Does nothing if the user requested zero results, ie /<a
556
+ href="size">posts?page</a>=0</p>
557
+
558
+ <p>First resolves the top-level resource, then processes each relevant
559
+ sideload</p>
560
+
561
+
562
+ </div>
563
+ </div>
564
+ <div class="tags">
565
+
566
+ <p class="tag_title">Returns:</p>
567
+ <ul class="return">
568
+
569
+ <li>
570
+
571
+
572
+ <span class='type'>(<tt>Array</tt>)</span>
573
+
574
+
575
+
576
+ &mdash;
577
+ <div class='inline'>
578
+ <p>an array of resolved model instances</p>
579
+ </div>
580
+
581
+ </li>
582
+
583
+ </ul>
584
+
585
+ <p class="tag_title">See Also:</p>
586
+ <ul class="see">
587
+
588
+ <li><span class='object_link'><a href="Resource.html#resolve-instance_method" title="JsonapiCompliable::Resource#resolve (method)">Resource#resolve</a></span></li>
589
+
590
+ </ul>
591
+
592
+ </div><table class="source_code">
593
+ <tr>
594
+ <td>
595
+ <pre class="lines">
596
+
597
+
598
+ 60
599
+ 61
600
+ 62
601
+ 63
602
+ 64
603
+ 65
604
+ 66
605
+ 67
606
+ 68</pre>
607
+ </td>
608
+ <td>
609
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scope.rb', line 60</span>
610
+
611
+ <span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span>
612
+ <span class='kw'>if</span> <span class='ivar'>@query</span><span class='period'>.</span><span class='id identifier rubyid_zero_results?'>zero_results?</span>
613
+ <span class='lbracket'>[</span><span class='rbracket'>]</span>
614
+ <span class='kw'>else</span>
615
+ <span class='id identifier rubyid_resolved'>resolved</span> <span class='op'>=</span> <span class='ivar'>@resource</span><span class='period'>.</span><span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='ivar'>@object</span><span class='rparen'>)</span>
616
+ <span class='id identifier rubyid_sideload'>sideload</span><span class='lparen'>(</span><span class='id identifier rubyid_resolved'>resolved</span><span class='comma'>,</span> <span class='id identifier rubyid_query_hash'>query_hash</span><span class='lbracket'>[</span><span class='symbol'>:include</span><span class='rbracket'>]</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_query_hash'>query_hash</span><span class='lbracket'>[</span><span class='symbol'>:include</span><span class='rbracket'>]</span>
617
+ <span class='id identifier rubyid_resolved'>resolved</span>
618
+ <span class='kw'>end</span>
619
+ <span class='kw'>end</span></pre>
620
+ </td>
621
+ </tr>
622
+ </table>
623
+ </div>
624
+
625
+ <div class="method_details ">
626
+ <h3 class="signature " id="resolve_stats-instance_method">
627
+
628
+ #<strong>resolve_stats</strong> &#x21d2; <tt>Hash</tt>
629
+
630
+
631
+
632
+
633
+
634
+ </h3><div class="docstring">
635
+ <div class="discussion">
636
+ <p class="note private">
637
+ <strong>This method is part of a private API.</strong>
638
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
639
+ </p>
640
+
641
+ <p>Resolve the requested stats. Returns hash like:</p>
642
+
643
+ <pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='label'>rating:</span> <span class='lbrace'>{</span> <span class='label'>average:</span> <span class='float'>5.5</span><span class='comma'>,</span> <span class='label'>maximum:</span> <span class='int'>9</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
644
+ </code></pre>
645
+
646
+
647
+ </div>
648
+ </div>
649
+ <div class="tags">
650
+
651
+ <p class="tag_title">Returns:</p>
652
+ <ul class="return">
653
+
654
+ <li>
655
+
656
+
657
+ <span class='type'>(<tt>Hash</tt>)</span>
658
+
659
+
660
+
661
+ &mdash;
662
+ <div class='inline'>
663
+ <p>the resolved stat info</p>
664
+ </div>
665
+
666
+ </li>
667
+
668
+ </ul>
669
+
670
+ </div><table class="source_code">
671
+ <tr>
672
+ <td>
673
+ <pre class="lines">
674
+
675
+
676
+ 47
677
+ 48
678
+ 49</pre>
679
+ </td>
680
+ <td>
681
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scope.rb', line 47</span>
682
+
683
+ <span class='kw'>def</span> <span class='id identifier rubyid_resolve_stats'>resolve_stats</span>
684
+ <span class='const'><span class='object_link'><a href="Stats.html" title="JsonapiCompliable::Stats (module)">Stats</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Stats/Payload.html" title="JsonapiCompliable::Stats::Payload (class)">Payload</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Stats/Payload.html#initialize-instance_method" title="JsonapiCompliable::Stats::Payload#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@resource</span><span class='comma'>,</span> <span class='id identifier rubyid_query_hash'>query_hash</span><span class='comma'>,</span> <span class='ivar'>@unpaginated_object</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_generate'><span class='object_link'><a href="Stats/Payload.html#generate-instance_method" title="JsonapiCompliable::Stats::Payload#generate (method)">generate</a></span></span>
685
+ <span class='kw'>end</span></pre>
686
+ </td>
687
+ </tr>
688
+ </table>
689
+ </div>
690
+
691
+ </div>
692
+
693
+ </div>
694
+
695
+ <div id="footer">
696
+ Generated on Fri May 5 15:53:22 2017 by
697
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
698
+ 0.9.9 (ruby-2.3.0).
699
+ </div>
700
+
701
+ </div>
702
+ </body>
703
+ </html>