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,454 @@
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::Scoping::Sort
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::Scoping::Sort";
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> &raquo; <span class='title'><span class='object_link'><a href="../Scoping.html" title="JsonapiCompliable::Scoping (module)">Scoping</a></span></span>
41
+ &raquo;
42
+ <span class="title">Sort</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::Scoping::Sort
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="Base.html" title="JsonapiCompliable::Scoping::Base (class)">Base</a></span></span>
73
+
74
+ <ul class="fullTree">
75
+ <li>Object</li>
76
+
77
+ <li class="next"><span class='object_link'><a href="Base.html" title="JsonapiCompliable::Scoping::Base (class)">Base</a></span></li>
78
+
79
+ <li class="next">JsonapiCompliable::Scoping::Sort</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/scoping/sort.rb</dd>
100
+ </dl>
101
+
102
+ </div>
103
+
104
+ <h2>Overview</h2><div class="docstring">
105
+ <div class="discussion">
106
+
107
+ <p>Apply sorting logic to the scope.</p>
108
+
109
+ <p>By default, sorting comes &#39;for free&#39;. To specify a custom sorting
110
+ proc:</p>
111
+
112
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>PostResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
113
+ <span class='id identifier rubyid_sort'>sort</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_att'>att</span><span class='comma'>,</span> <span class='id identifier rubyid_dir'>dir</span><span class='op'>|</span>
114
+ <span class='id identifier rubyid_int'>int</span> <span class='op'>=</span> <span class='id identifier rubyid_dir'>dir</span> <span class='op'>==</span> <span class='symbol'>:desc</span> <span class='op'>?</span> <span class='op'>-</span><span class='int'>1</span> <span class='op'>:</span> <span class='int'>1</span>
115
+ <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_sort_by'>sort_by</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span> <span class='id identifier rubyid_x'>x</span><span class='lbracket'>[</span><span class='id identifier rubyid_att'>att</span><span class='rbracket'>]</span> <span class='op'>*</span> <span class='id identifier rubyid_int'>int</span> <span class='rbrace'>}</span>
116
+ <span class='kw'>end</span>
117
+ <span class='kw'>end</span>
118
+ </code></pre>
119
+
120
+ <p>The sorting proc will be called once for each sort att/dir requested.</p>
121
+
122
+
123
+ </div>
124
+ </div>
125
+ <div class="tags">
126
+
127
+
128
+ <p class="tag_title">See Also:</p>
129
+ <ul class="see">
130
+
131
+ <li><span class='object_link'><a href="../Resource.html#sort-class_method" title="JsonapiCompliable::Resource.sort (method)">Resource.sort</a></span></li>
132
+
133
+ </ul>
134
+
135
+ </div>
136
+
137
+
138
+
139
+
140
+
141
+ <h2>Instance Attribute Summary</h2>
142
+
143
+ <h3 class="inherited">Attributes inherited from <span class='object_link'><a href="Base.html" title="JsonapiCompliable::Scoping::Base (class)">Base</a></span></h3>
144
+ <p class="inherited"><span class='object_link'><a href="Base.html#query_hash-instance_method" title="JsonapiCompliable::Scoping::Base#query_hash (method)">#query_hash</a></span>, <span class='object_link'><a href="Base.html#resource-instance_method" title="JsonapiCompliable::Scoping::Base#resource (method)">#resource</a></span></p>
145
+
146
+
147
+
148
+ <h2>
149
+ Instance Method Summary
150
+ <small><a href="#" class="summary_toggle">collapse</a></small>
151
+ </h2>
152
+
153
+ <ul class="summary">
154
+
155
+ <li class="public ">
156
+ <span class="summary_signature">
157
+
158
+ <a href="#apply_custom_scope-instance_method" title="#apply_custom_scope (instance method)">#<strong>apply_custom_scope</strong> &#x21d2; Object </a>
159
+
160
+
161
+
162
+ </span>
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+ <span class="summary_desc"><div class='inline'>
173
+ <p>Apply custom scoping proc configured via Resource DSL.</p>
174
+ </div></span>
175
+
176
+ </li>
177
+
178
+
179
+ <li class="public ">
180
+ <span class="summary_signature">
181
+
182
+ <a href="#apply_standard_scope-instance_method" title="#apply_standard_scope (instance method)">#<strong>apply_standard_scope</strong> &#x21d2; Object </a>
183
+
184
+
185
+
186
+ </span>
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+ <span class="summary_desc"><div class='inline'>
197
+ <p>Apply default scope logic via Resource adapter.</p>
198
+ </div></span>
199
+
200
+ </li>
201
+
202
+
203
+ <li class="public ">
204
+ <span class="summary_signature">
205
+
206
+ <a href="#custom_scope-instance_method" title="#custom_scope (instance method)">#<strong>custom_scope</strong> &#x21d2; Proc, Nil </a>
207
+
208
+
209
+
210
+ </span>
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'>
221
+ <p>The custom proc specified by Resource DSL.</p>
222
+ </div></span>
223
+
224
+ </li>
225
+
226
+
227
+ </ul>
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+ <h3 class="inherited">Methods inherited from <span class='object_link'><a href="Base.html" title="JsonapiCompliable::Scoping::Base (class)">Base</a></span></h3>
240
+ <p class="inherited"><span class='object_link'><a href="Base.html#apply-instance_method" title="JsonapiCompliable::Scoping::Base#apply (method)">#apply</a></span>, <span class='object_link'><a href="Base.html#apply%3F-instance_method" title="JsonapiCompliable::Scoping::Base#apply? (method)">#apply?</a></span>, <span class='object_link'><a href="Base.html#initialize-instance_method" title="JsonapiCompliable::Scoping::Base#initialize (method)">#initialize</a></span></p>
241
+ <div id="constructor_details" class="method_details_list">
242
+ <h2>Constructor Details</h2>
243
+
244
+ <p class="notice">This class inherits a constructor from <span class='object_link'><a href="Base.html#initialize-instance_method" title="JsonapiCompliable::Scoping::Base#initialize (method)">JsonapiCompliable::Scoping::Base</a></span></p>
245
+
246
+ </div>
247
+
248
+
249
+ <div id="instance_method_details" class="method_details_list">
250
+ <h2>Instance Method Details</h2>
251
+
252
+
253
+ <div class="method_details first">
254
+ <h3 class="signature first" id="apply_custom_scope-instance_method">
255
+
256
+ #<strong>apply_custom_scope</strong> &#x21d2; <tt>Object</tt>
257
+
258
+
259
+
260
+
261
+
262
+ </h3><div class="docstring">
263
+ <div class="discussion">
264
+
265
+ <p>Apply custom scoping proc configured via Resource DSL</p>
266
+
267
+
268
+ </div>
269
+ </div>
270
+ <div class="tags">
271
+
272
+ <p class="tag_title">Returns:</p>
273
+ <ul class="return">
274
+
275
+ <li>
276
+
277
+
278
+ <span class='type'></span>
279
+
280
+
281
+
282
+
283
+ <div class='inline'>
284
+ <p>the scope we are chaining/modifying</p>
285
+ </div>
286
+
287
+ </li>
288
+
289
+ </ul>
290
+
291
+ </div><table class="source_code">
292
+ <tr>
293
+ <td>
294
+ <pre class="lines">
295
+
296
+
297
+ 32
298
+ 33
299
+ 34
300
+ 35
301
+ 36
302
+ 37</pre>
303
+ </td>
304
+ <td>
305
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scoping/sort.rb', line 32</span>
306
+
307
+ <span class='kw'>def</span> <span class='id identifier rubyid_apply_custom_scope'>apply_custom_scope</span>
308
+ <span class='id identifier rubyid_each_sort'>each_sort</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='op'>|</span>
309
+ <span class='ivar'>@scope</span> <span class='op'>=</span> <span class='id identifier rubyid_custom_scope'>custom_scope</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='lparen'>(</span><span class='ivar'>@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>
310
+ <span class='kw'>end</span>
311
+ <span class='ivar'>@scope</span>
312
+ <span class='kw'>end</span></pre>
313
+ </td>
314
+ </tr>
315
+ </table>
316
+ </div>
317
+
318
+ <div class="method_details ">
319
+ <h3 class="signature " id="apply_standard_scope-instance_method">
320
+
321
+ #<strong>apply_standard_scope</strong> &#x21d2; <tt>Object</tt>
322
+
323
+
324
+
325
+
326
+
327
+ </h3><div class="docstring">
328
+ <div class="discussion">
329
+
330
+ <p>Apply default scope logic via Resource adapter</p>
331
+
332
+
333
+ </div>
334
+ </div>
335
+ <div class="tags">
336
+
337
+ <p class="tag_title">Returns:</p>
338
+ <ul class="return">
339
+
340
+ <li>
341
+
342
+
343
+ <span class='type'></span>
344
+
345
+
346
+
347
+
348
+ <div class='inline'>
349
+ <p>the scope we are chaining/modifying</p>
350
+ </div>
351
+
352
+ </li>
353
+
354
+ </ul>
355
+
356
+ </div><table class="source_code">
357
+ <tr>
358
+ <td>
359
+ <pre class="lines">
360
+
361
+
362
+ 23
363
+ 24
364
+ 25
365
+ 26
366
+ 27
367
+ 28</pre>
368
+ </td>
369
+ <td>
370
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scoping/sort.rb', line 23</span>
371
+
372
+ <span class='kw'>def</span> <span class='id identifier rubyid_apply_standard_scope'>apply_standard_scope</span>
373
+ <span class='id identifier rubyid_each_sort'>each_sort</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_direction'>direction</span><span class='op'>|</span>
374
+ <span class='ivar'>@scope</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_adapter'>adapter</span><span class='period'>.</span><span class='id identifier rubyid_order'>order</span><span class='lparen'>(</span><span class='ivar'>@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>
375
+ <span class='kw'>end</span>
376
+ <span class='ivar'>@scope</span>
377
+ <span class='kw'>end</span></pre>
378
+ </td>
379
+ </tr>
380
+ </table>
381
+ </div>
382
+
383
+ <div class="method_details ">
384
+ <h3 class="signature " id="custom_scope-instance_method">
385
+
386
+ #<strong>custom_scope</strong> &#x21d2; <tt>Proc</tt>, <tt>Nil</tt>
387
+
388
+
389
+
390
+
391
+
392
+ </h3><div class="docstring">
393
+ <div class="discussion">
394
+
395
+ <p>Returns The custom proc specified by Resource DSL</p>
396
+
397
+
398
+ </div>
399
+ </div>
400
+ <div class="tags">
401
+
402
+ <p class="tag_title">Returns:</p>
403
+ <ul class="return">
404
+
405
+ <li>
406
+
407
+
408
+ <span class='type'>(<tt>Proc</tt>, <tt>Nil</tt>)</span>
409
+
410
+
411
+
412
+ &mdash;
413
+ <div class='inline'>
414
+ <p>The custom proc specified by Resource DSL</p>
415
+ </div>
416
+
417
+ </li>
418
+
419
+ </ul>
420
+
421
+ </div><table class="source_code">
422
+ <tr>
423
+ <td>
424
+ <pre class="lines">
425
+
426
+
427
+ 17
428
+ 18
429
+ 19</pre>
430
+ </td>
431
+ <td>
432
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/scoping/sort.rb', line 17</span>
433
+
434
+ <span class='kw'>def</span> <span class='id identifier rubyid_custom_scope'>custom_scope</span>
435
+ <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_sorting'>sorting</span>
436
+ <span class='kw'>end</span></pre>
437
+ </td>
438
+ </tr>
439
+ </table>
440
+ </div>
441
+
442
+ </div>
443
+
444
+ </div>
445
+
446
+ <div id="footer">
447
+ Generated on Fri May 5 15:53:22 2017 by
448
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
449
+ 0.9.9 (ruby-2.3.0).
450
+ </div>
451
+
452
+ </div>
453
+ </body>
454
+ </html>