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,117 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Module: JsonapiCompliable::Stats
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::Stats";
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">Stats</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="../class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Module: JsonapiCompliable::Stats
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ <dl>
80
+ <dt>Defined in:</dt>
81
+ <dd>lib/jsonapi_compliable/stats/dsl.rb<span class="defines">,<br />
82
+ lib/jsonapi_compliable/stats/payload.rb</span>
83
+ </dd>
84
+ </dl>
85
+
86
+ </div>
87
+
88
+ <h2>Defined Under Namespace</h2>
89
+ <p class="children">
90
+
91
+
92
+
93
+
94
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Stats/DSL.html" title="JsonapiCompliable::Stats::DSL (class)">DSL</a></span>, <span class='object_link'><a href="Stats/Payload.html" title="JsonapiCompliable::Stats::Payload (class)">Payload</a></span>
95
+
96
+
97
+ </p>
98
+
99
+
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ </div>
108
+
109
+ <div id="footer">
110
+ Generated on Fri May 5 15:53:21 2017 by
111
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
112
+ 0.9.9 (ruby-2.3.0).
113
+ </div>
114
+
115
+ </div>
116
+ </body>
117
+ </html>
@@ -0,0 +1,999 @@
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::Stats::DSL
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::Stats::DSL";
19
+ relpath = '../../';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="../../class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="../../_index.html">Index (D)</a> &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="../Stats.html" title="JsonapiCompliable::Stats (module)">Stats</a></span></span>
41
+ &raquo;
42
+ <span class="title">DSL</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::Stats::DSL
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::Stats::DSL</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/stats/dsl.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+
105
+ <p>Provides an easier interface to stats scoping.</p>
106
+
107
+ <p>Used within Resource DSL:</p>
108
+
109
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_allow_stat'>allow_stat</span> <span class='label'>total:</span> <span class='lbracket'>[</span><span class='symbol'>:count</span><span class='rbracket'>]</span> <span class='kw'>do</span>
110
+ <span class='comment'># ... eval&#39;d in Stats::DSL context! ...
111
+ </span><span class='kw'>end</span>
112
+ </code></pre>
113
+
114
+ <p>This allows us to define arbitrary stats:</p>
115
+
116
+ <pre class="code ruby"><code class="ruby">allow_stat total: [:count] do
117
+ standard_deviation { |scope, attr| ... }
118
+ end</code></pre>
119
+
120
+ <p>And use convenience methods:</p>
121
+
122
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_allow_stat'>allow_stat</span> <span class='symbol'>:rating</span> <span class='kw'>do</span>
123
+ <span class='id identifier rubyid_count!'>count!</span>
124
+ <span class='id identifier rubyid_average!'>average!</span>
125
+ <span class='kw'>end</span>
126
+ </code></pre>
127
+
128
+
129
+ </div>
130
+ </div>
131
+ <div class="tags">
132
+
133
+
134
+ <p class="tag_title">See Also:</p>
135
+ <ul class="see">
136
+
137
+ <li><span class='object_link'><a href="../Resource.html#allow_stat-class_method" title="JsonapiCompliable::Resource.allow_stat (method)">Resource.allow_stat</a></span></li>
138
+
139
+ </ul>
140
+
141
+ </div>
142
+
143
+
144
+
145
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
146
+ <ul class="summary">
147
+
148
+ <li class="public ">
149
+ <span class="summary_signature">
150
+
151
+ <a href="#calculations-instance_method" title="#calculations (instance method)">#<strong>calculations</strong> &#x21d2; Hash </a>
152
+
153
+
154
+
155
+ </span>
156
+
157
+
158
+
159
+
160
+ <span class="note title readonly">readonly</span>
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+ <span class="summary_desc"><div class='inline'>
171
+ <p>procs for various metrics.</p>
172
+ </div></span>
173
+
174
+ </li>
175
+
176
+
177
+ <li class="public ">
178
+ <span class="summary_signature">
179
+
180
+ <a href="#name-instance_method" title="#name (instance method)">#<strong>name</strong> &#x21d2; Symbol </a>
181
+
182
+
183
+
184
+ </span>
185
+
186
+
187
+
188
+
189
+ <span class="note title readonly">readonly</span>
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ <span class="summary_desc"><div class='inline'>
200
+ <p>the stat, e.g.</p>
201
+ </div></span>
202
+
203
+ </li>
204
+
205
+
206
+ </ul>
207
+
208
+
209
+
210
+
211
+
212
+ <h2>
213
+ Instance Method Summary
214
+ <small><a href="#" class="summary_toggle">collapse</a></small>
215
+ </h2>
216
+
217
+ <ul class="summary">
218
+
219
+ <li class="public ">
220
+ <span class="summary_signature">
221
+
222
+ <a href="#average!-instance_method" title="#average! (instance method)">#<strong>average!</strong> &#x21d2; Object </a>
223
+
224
+
225
+
226
+ </span>
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+ <span class="summary_desc"><div class='inline'>
237
+ <p>Convenience method for default :average proc.</p>
238
+ </div></span>
239
+
240
+ </li>
241
+
242
+
243
+ <li class="public ">
244
+ <span class="summary_signature">
245
+
246
+ <a href="#calculation-instance_method" title="#calculation (instance method)">#<strong>calculation</strong>(name) &#x21d2; Proc </a>
247
+
248
+
249
+
250
+ </span>
251
+
252
+
253
+
254
+
255
+
256
+
257
+
258
+
259
+
260
+ <span class="summary_desc"><div class='inline'>
261
+ <p>Grab a calculation proc.</p>
262
+ </div></span>
263
+
264
+ </li>
265
+
266
+
267
+ <li class="public ">
268
+ <span class="summary_signature">
269
+
270
+ <a href="#count!-instance_method" title="#count! (instance method)">#<strong>count!</strong> &#x21d2; Object </a>
271
+
272
+
273
+
274
+ </span>
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+ <span class="summary_desc"><div class='inline'>
285
+ <p>Convenience method for default :count proc.</p>
286
+ </div></span>
287
+
288
+ </li>
289
+
290
+
291
+ <li class="public ">
292
+ <span class="summary_signature">
293
+
294
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(adapter, config) &#x21d2; DSL </a>
295
+
296
+
297
+
298
+ </span>
299
+
300
+
301
+ <span class="note title constructor">constructor</span>
302
+
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+ <span class="summary_desc"><div class='inline'>
311
+ <p>A new instance of DSL.</p>
312
+ </div></span>
313
+
314
+ </li>
315
+
316
+
317
+ <li class="public ">
318
+ <span class="summary_signature">
319
+
320
+ <a href="#maximum!-instance_method" title="#maximum! (instance method)">#<strong>maximum!</strong> &#x21d2; Object </a>
321
+
322
+
323
+
324
+ </span>
325
+
326
+
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+ <span class="summary_desc"><div class='inline'>
335
+ <p>Convenience method for default :maximum proc.</p>
336
+ </div></span>
337
+
338
+ </li>
339
+
340
+
341
+ <li class="public ">
342
+ <span class="summary_signature">
343
+
344
+ <a href="#method_missing-instance_method" title="#method_missing (instance method)">#<strong>method_missing</strong>(meth, *args, &amp;blk) &#x21d2; Object </a>
345
+
346
+
347
+
348
+ </span>
349
+
350
+
351
+
352
+
353
+
354
+
355
+ <span class="private note title">private</span>
356
+
357
+
358
+ <span class="summary_desc"><div class='inline'>
359
+ <p>Used for defining arbitrary stats within the DSL:.</p>
360
+ </div></span>
361
+
362
+ </li>
363
+
364
+
365
+ <li class="public ">
366
+ <span class="summary_signature">
367
+
368
+ <a href="#minimum!-instance_method" title="#minimum! (instance method)">#<strong>minimum!</strong> &#x21d2; Object </a>
369
+
370
+
371
+
372
+ </span>
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+ <span class="summary_desc"><div class='inline'>
383
+ <p>Convenience method for default :minimum proc.</p>
384
+ </div></span>
385
+
386
+ </li>
387
+
388
+
389
+ <li class="public ">
390
+ <span class="summary_signature">
391
+
392
+ <a href="#sum!-instance_method" title="#sum! (instance method)">#<strong>sum!</strong> &#x21d2; Object </a>
393
+
394
+
395
+
396
+ </span>
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+ <span class="summary_desc"><div class='inline'>
407
+ <p>Convenience method for default :sum proc.</p>
408
+ </div></span>
409
+
410
+ </li>
411
+
412
+
413
+ </ul>
414
+
415
+
416
+ <div id="constructor_details" class="method_details_list">
417
+ <h2>Constructor Details</h2>
418
+
419
+ <div class="method_details first">
420
+ <h3 class="signature first" id="initialize-instance_method">
421
+
422
+ #<strong>initialize</strong>(adapter, config) &#x21d2; <tt><span class='object_link'><a href="" title="JsonapiCompliable::Stats::DSL (class)">DSL</a></span></tt>
423
+
424
+
425
+
426
+
427
+
428
+ </h3><div class="docstring">
429
+ <div class="discussion">
430
+
431
+ <p>Returns a new instance of DSL</p>
432
+
433
+
434
+ </div>
435
+ </div>
436
+ <div class="tags">
437
+ <p class="tag_title">Parameters:</p>
438
+ <ul class="param">
439
+
440
+ <li>
441
+
442
+ <span class='name'>adapter</span>
443
+
444
+
445
+ <span class='type'>(<tt><span class='object_link'><a href="../Adapters/Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Adapters::Abstract</a></span></tt>)</span>
446
+
447
+
448
+
449
+ &mdash;
450
+ <div class='inline'>
451
+ <p>the Resource adapter</p>
452
+ </div>
453
+
454
+ </li>
455
+
456
+ <li>
457
+
458
+ <span class='name'>config</span>
459
+
460
+
461
+ <span class='type'>(<tt>Symbol</tt>, <tt>Hash</tt>)</span>
462
+
463
+
464
+
465
+ &mdash;
466
+ <div class='inline'>
467
+ <p>example: <code>:total</code> or <tt>{ total: [:count] }</tt></p>
468
+ </div>
469
+
470
+ </li>
471
+
472
+ </ul>
473
+
474
+
475
+ </div><table class="source_code">
476
+ <tr>
477
+ <td>
478
+ <pre class="lines">
479
+
480
+
481
+ 32
482
+ 33
483
+ 34
484
+ 35
485
+ 36
486
+ 37
487
+ 38
488
+ 39</pre>
489
+ </td>
490
+ <td>
491
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 32</span>
492
+
493
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_adapter'>adapter</span><span class='comma'>,</span> <span class='id identifier rubyid_config'>config</span><span class='rparen'>)</span>
494
+ <span class='id identifier rubyid_config'>config</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_config'>config</span> <span class='op'>=&gt;</span> <span class='lbracket'>[</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Symbol</span><span class='rparen'>)</span>
495
+
496
+ <span class='ivar'>@adapter</span> <span class='op'>=</span> <span class='id identifier rubyid_adapter'>adapter</span>
497
+ <span class='ivar'>@calculations</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
498
+ <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
499
+ <span class='const'>Array</span><span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:#{</span><span class='id identifier rubyid_c'>c</span><span class='embexpr_end'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='rbrace'>}</span>
500
+ <span class='kw'>end</span></pre>
501
+ </td>
502
+ </tr>
503
+ </table>
504
+ </div>
505
+
506
+ </div>
507
+ <div id="method_missing_details" class="method_details_list">
508
+ <h2>Dynamic Method Handling</h2>
509
+ <p class="notice this">
510
+ This class handles dynamic methods through the <tt>method_missing</tt> method
511
+
512
+ </p>
513
+
514
+ <div class="method_details first">
515
+ <h3 class="signature first" id="method_missing-instance_method">
516
+
517
+ #<strong>method_missing</strong>(meth, *args, &amp;blk) &#x21d2; <tt>Object</tt>
518
+
519
+
520
+
521
+
522
+
523
+ </h3><div class="docstring">
524
+ <div class="discussion">
525
+ <p class="note private">
526
+ <strong>This method is part of a private API.</strong>
527
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
528
+ </p>
529
+
530
+ <p>Used for defining arbitrary stats within the DSL:</p>
531
+
532
+ <pre class="code ruby"><code class="ruby">allow_stat :total do
533
+ standard_deviation { |scope, attr| ... }
534
+ end</code></pre>
535
+
536
+ <p>…will hit <code>method_missing</code> and store the proc for future
537
+ reference.</p>
538
+
539
+
540
+ </div>
541
+ </div>
542
+ <div class="tags">
543
+
544
+
545
+ </div><table class="source_code">
546
+ <tr>
547
+ <td>
548
+ <pre class="lines">
549
+
550
+
551
+ 49
552
+ 50
553
+ 51</pre>
554
+ </td>
555
+ <td>
556
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 49</span>
557
+
558
+ <span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_meth'>meth</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
559
+ <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='id identifier rubyid_meth'>meth</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_blk'>blk</span>
560
+ <span class='kw'>end</span></pre>
561
+ </td>
562
+ </tr>
563
+ </table>
564
+ </div>
565
+
566
+ </div>
567
+
568
+ <div id="instance_attr_details" class="attr_details">
569
+ <h2>Instance Attribute Details</h2>
570
+
571
+
572
+ <span id=""></span>
573
+ <div class="method_details first">
574
+ <h3 class="signature first" id="calculations-instance_method">
575
+
576
+ #<strong>calculations</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
577
+
578
+
579
+
580
+
581
+
582
+ </h3><div class="docstring">
583
+ <div class="discussion">
584
+
585
+ <p>procs for various metrics</p>
586
+
587
+
588
+ </div>
589
+ </div>
590
+ <div class="tags">
591
+
592
+ <p class="tag_title">Returns:</p>
593
+ <ul class="return">
594
+
595
+ <li>
596
+
597
+
598
+ <span class='type'>(<tt>Hash</tt>)</span>
599
+
600
+
601
+
602
+ &mdash;
603
+ <div class='inline'>
604
+ <p>the current value of calculations</p>
605
+ </div>
606
+
607
+ </li>
608
+
609
+ </ul>
610
+
611
+ </div><table class="source_code">
612
+ <tr>
613
+ <td>
614
+ <pre class="lines">
615
+
616
+
617
+ 27
618
+ 28
619
+ 29</pre>
620
+ </td>
621
+ <td>
622
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 27</span>
623
+
624
+ <span class='kw'>def</span> <span class='id identifier rubyid_calculations'>calculations</span>
625
+ <span class='ivar'>@calculations</span>
626
+ <span class='kw'>end</span></pre>
627
+ </td>
628
+ </tr>
629
+ </table>
630
+ </div>
631
+
632
+
633
+ <span id=""></span>
634
+ <div class="method_details ">
635
+ <h3 class="signature " id="name-instance_method">
636
+
637
+ #<strong>name</strong> &#x21d2; <tt>Symbol</tt> <span class="extras">(readonly)</span>
638
+
639
+
640
+
641
+
642
+
643
+ </h3><div class="docstring">
644
+ <div class="discussion">
645
+
646
+ <p>the stat, e.g. :total</p>
647
+
648
+
649
+ </div>
650
+ </div>
651
+ <div class="tags">
652
+
653
+ <p class="tag_title">Returns:</p>
654
+ <ul class="return">
655
+
656
+ <li>
657
+
658
+
659
+ <span class='type'>(<tt>Symbol</tt>)</span>
660
+
661
+
662
+
663
+ &mdash;
664
+ <div class='inline'>
665
+ <p>the current value of name</p>
666
+ </div>
667
+
668
+ </li>
669
+
670
+ </ul>
671
+
672
+ </div><table class="source_code">
673
+ <tr>
674
+ <td>
675
+ <pre class="lines">
676
+
677
+
678
+ 27
679
+ 28
680
+ 29</pre>
681
+ </td>
682
+ <td>
683
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 27</span>
684
+
685
+ <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
686
+ <span class='ivar'>@name</span>
687
+ <span class='kw'>end</span></pre>
688
+ </td>
689
+ </tr>
690
+ </table>
691
+ </div>
692
+
693
+ </div>
694
+
695
+
696
+ <div id="instance_method_details" class="method_details_list">
697
+ <h2>Instance Method Details</h2>
698
+
699
+
700
+ <div class="method_details first">
701
+ <h3 class="signature first" id="average!-instance_method">
702
+
703
+ #<strong>average!</strong> &#x21d2; <tt>Object</tt>
704
+
705
+
706
+
707
+
708
+
709
+ </h3><div class="docstring">
710
+ <div class="discussion">
711
+
712
+ <p>Convenience method for default :average proc</p>
713
+
714
+
715
+ </div>
716
+ </div>
717
+ <div class="tags">
718
+
719
+
720
+ </div><table class="source_code">
721
+ <tr>
722
+ <td>
723
+ <pre class="lines">
724
+
725
+
726
+ 74
727
+ 75
728
+ 76</pre>
729
+ </td>
730
+ <td>
731
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 74</span>
732
+
733
+ <span class='kw'>def</span> <span class='id identifier rubyid_average!'>average!</span>
734
+ <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='symbol'>:average</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:average</span><span class='rparen'>)</span>
735
+ <span class='kw'>end</span></pre>
736
+ </td>
737
+ </tr>
738
+ </table>
739
+ </div>
740
+
741
+ <div class="method_details ">
742
+ <h3 class="signature " id="calculation-instance_method">
743
+
744
+ #<strong>calculation</strong>(name) &#x21d2; <tt>Proc</tt>
745
+
746
+
747
+
748
+
749
+
750
+ </h3><div class="docstring">
751
+ <div class="discussion">
752
+
753
+ <p>Grab a calculation proc. Raises error if no corresponding stat has been
754
+ configured.</p>
755
+
756
+
757
+ </div>
758
+ </div>
759
+ <div class="tags">
760
+ <p class="tag_title">Parameters:</p>
761
+ <ul class="param">
762
+
763
+ <li>
764
+
765
+ <span class='name'>name</span>
766
+
767
+
768
+ <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
769
+
770
+
771
+
772
+ &mdash;
773
+ <div class='inline'>
774
+ <p>the name of the calculation, e.g. <code>:total</code></p>
775
+ </div>
776
+
777
+ </li>
778
+
779
+ </ul>
780
+
781
+ <p class="tag_title">Returns:</p>
782
+ <ul class="return">
783
+
784
+ <li>
785
+
786
+
787
+ <span class='type'>(<tt>Proc</tt>)</span>
788
+
789
+
790
+
791
+ &mdash;
792
+ <div class='inline'>
793
+ <p>the proc to run the calculation</p>
794
+ </div>
795
+
796
+ </li>
797
+
798
+ </ul>
799
+
800
+ </div><table class="source_code">
801
+ <tr>
802
+ <td>
803
+ <pre class="lines">
804
+
805
+
806
+ 58
807
+ 59
808
+ 60
809
+ 61</pre>
810
+ </td>
811
+ <td>
812
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 58</span>
813
+
814
+ <span class='kw'>def</span> <span class='id identifier rubyid_calculation'>calculation</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
815
+ <span class='id identifier rubyid_callable'>callable</span> <span class='op'>=</span> <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rbracket'>]</span>
816
+ <span class='id identifier rubyid_callable'>callable</span> <span class='op'>||</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../Errors.html" title="JsonapiCompliable::Errors (module)">Errors</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="../Errors/StatNotFound.html" title="JsonapiCompliable::Errors::StatNotFound (class)">StatNotFound</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="../Errors/StatNotFound.html#initialize-instance_method" title="JsonapiCompliable::Errors::StatNotFound#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='ivar'>@name</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='rparen'>)</span>
817
+ <span class='kw'>end</span></pre>
818
+ </td>
819
+ </tr>
820
+ </table>
821
+ </div>
822
+
823
+ <div class="method_details ">
824
+ <h3 class="signature " id="count!-instance_method">
825
+
826
+ #<strong>count!</strong> &#x21d2; <tt>Object</tt>
827
+
828
+
829
+
830
+
831
+
832
+ </h3><div class="docstring">
833
+ <div class="discussion">
834
+
835
+ <p>Convenience method for default :count proc</p>
836
+
837
+
838
+ </div>
839
+ </div>
840
+ <div class="tags">
841
+
842
+
843
+ </div><table class="source_code">
844
+ <tr>
845
+ <td>
846
+ <pre class="lines">
847
+
848
+
849
+ 64
850
+ 65
851
+ 66</pre>
852
+ </td>
853
+ <td>
854
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 64</span>
855
+
856
+ <span class='kw'>def</span> <span class='id identifier rubyid_count!'>count!</span>
857
+ <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='symbol'>:count</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:count</span><span class='rparen'>)</span>
858
+ <span class='kw'>end</span></pre>
859
+ </td>
860
+ </tr>
861
+ </table>
862
+ </div>
863
+
864
+ <div class="method_details ">
865
+ <h3 class="signature " id="maximum!-instance_method">
866
+
867
+ #<strong>maximum!</strong> &#x21d2; <tt>Object</tt>
868
+
869
+
870
+
871
+
872
+
873
+ </h3><div class="docstring">
874
+ <div class="discussion">
875
+
876
+ <p>Convenience method for default :maximum proc</p>
877
+
878
+
879
+ </div>
880
+ </div>
881
+ <div class="tags">
882
+
883
+
884
+ </div><table class="source_code">
885
+ <tr>
886
+ <td>
887
+ <pre class="lines">
888
+
889
+
890
+ 79
891
+ 80
892
+ 81</pre>
893
+ </td>
894
+ <td>
895
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 79</span>
896
+
897
+ <span class='kw'>def</span> <span class='id identifier rubyid_maximum!'>maximum!</span>
898
+ <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='symbol'>:maximum</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:maximum</span><span class='rparen'>)</span>
899
+ <span class='kw'>end</span></pre>
900
+ </td>
901
+ </tr>
902
+ </table>
903
+ </div>
904
+
905
+ <div class="method_details ">
906
+ <h3 class="signature " id="minimum!-instance_method">
907
+
908
+ #<strong>minimum!</strong> &#x21d2; <tt>Object</tt>
909
+
910
+
911
+
912
+
913
+
914
+ </h3><div class="docstring">
915
+ <div class="discussion">
916
+
917
+ <p>Convenience method for default :minimum proc</p>
918
+
919
+
920
+ </div>
921
+ </div>
922
+ <div class="tags">
923
+
924
+
925
+ </div><table class="source_code">
926
+ <tr>
927
+ <td>
928
+ <pre class="lines">
929
+
930
+
931
+ 84
932
+ 85
933
+ 86</pre>
934
+ </td>
935
+ <td>
936
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 84</span>
937
+
938
+ <span class='kw'>def</span> <span class='id identifier rubyid_minimum!'>minimum!</span>
939
+ <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='symbol'>:minimum</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:minimum</span><span class='rparen'>)</span>
940
+ <span class='kw'>end</span></pre>
941
+ </td>
942
+ </tr>
943
+ </table>
944
+ </div>
945
+
946
+ <div class="method_details ">
947
+ <h3 class="signature " id="sum!-instance_method">
948
+
949
+ #<strong>sum!</strong> &#x21d2; <tt>Object</tt>
950
+
951
+
952
+
953
+
954
+
955
+ </h3><div class="docstring">
956
+ <div class="discussion">
957
+
958
+ <p>Convenience method for default :sum proc</p>
959
+
960
+
961
+ </div>
962
+ </div>
963
+ <div class="tags">
964
+
965
+
966
+ </div><table class="source_code">
967
+ <tr>
968
+ <td>
969
+ <pre class="lines">
970
+
971
+
972
+ 69
973
+ 70
974
+ 71</pre>
975
+ </td>
976
+ <td>
977
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/stats/dsl.rb', line 69</span>
978
+
979
+ <span class='kw'>def</span> <span class='id identifier rubyid_sum!'>sum!</span>
980
+ <span class='ivar'>@calculations</span><span class='lbracket'>[</span><span class='symbol'>:sum</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='ivar'>@adapter</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='symbol'>:sum</span><span class='rparen'>)</span>
981
+ <span class='kw'>end</span></pre>
982
+ </td>
983
+ </tr>
984
+ </table>
985
+ </div>
986
+
987
+ </div>
988
+
989
+ </div>
990
+
991
+ <div id="footer">
992
+ Generated on Fri May 5 15:53:22 2017 by
993
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
994
+ 0.9.9 (ruby-2.3.0).
995
+ </div>
996
+
997
+ </div>
998
+ </body>
999
+ </html>