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,216 @@
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::SerializableTempId
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::SerializableTempId";
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">SerializableTempId</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::SerializableTempId
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/extensions/temp_id.rb</dd>
82
+ </dl>
83
+
84
+ </div>
85
+
86
+ <h2>Overview</h2><div class="docstring">
87
+ <div class="discussion">
88
+
89
+ <p>If the object we are serializing has the instance variable
90
+ <tt>@_jsonapi_temp_id</tt>, render <code>temp-id</code> in the
91
+ <a href="http://jsonapi.org/format/#document-resource-identifier-objects" target="_parent" title="resource identifier">resource identifier</a></p>
92
+
93
+ <p>Why? Well, when the request is a nested POST, creating the main entity as
94
+ well as relationships, we need some way of telling the client, “hey, the
95
+ object you have in memory, that you just sent to the server, has been
96
+ persisted and now has id X”.</p>
97
+
98
+ <p><tt>@_jsonapi_temp_id</tt> is set within this library. You should never have to
99
+ reference it directly.</p>
100
+
101
+
102
+ </div>
103
+ </div>
104
+ <div class="tags">
105
+
106
+
107
+ </div>
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+ <h2>
116
+ Instance Method Summary
117
+ <small><a href="#" class="summary_toggle">collapse</a></small>
118
+ </h2>
119
+
120
+ <ul class="summary">
121
+
122
+ <li class="public ">
123
+ <span class="summary_signature">
124
+
125
+ <a href="#as_jsonapi-instance_method" title="#as_jsonapi (instance method)">#<strong>as_jsonapi</strong> &#x21d2; Object </a>
126
+
127
+
128
+
129
+ </span>
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <span class="summary_desc"><div class='inline'>
140
+ <p>Common interface for jsonapi-rb extensions.</p>
141
+ </div></span>
142
+
143
+ </li>
144
+
145
+
146
+ </ul>
147
+
148
+
149
+
150
+
151
+ <div id="instance_method_details" class="method_details_list">
152
+ <h2>Instance Method Details</h2>
153
+
154
+
155
+ <div class="method_details first">
156
+ <h3 class="signature first" id="as_jsonapi-instance_method">
157
+
158
+ #<strong>as_jsonapi</strong> &#x21d2; <tt>Object</tt>
159
+
160
+
161
+
162
+
163
+
164
+ </h3><div class="docstring">
165
+ <div class="discussion">
166
+
167
+ <p>Common interface for jsonapi-rb extensions</p>
168
+
169
+
170
+ </div>
171
+ </div>
172
+ <div class="tags">
173
+
174
+
175
+ </div><table class="source_code">
176
+ <tr>
177
+ <td>
178
+ <pre class="lines">
179
+
180
+
181
+ 14
182
+ 15
183
+ 16
184
+ 17
185
+ 18
186
+ 19
187
+ 20</pre>
188
+ </td>
189
+ <td>
190
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/extensions/temp_id.rb', line 14</span>
191
+
192
+ <span class='kw'>def</span> <span class='id identifier rubyid_as_jsonapi'>as_jsonapi</span><span class='lparen'>(</span><span class='op'>*</span><span class='rparen'>)</span>
193
+ <span class='kw'>super</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
194
+ <span class='kw'>if</span> <span class='id identifier rubyid_temp_id'>temp_id</span> <span class='op'>=</span> <span class='ivar'>@object</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='symbol'>:@_jsonapi_temp_id</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
195
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='symbol'>:temp-id</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_temp_id'>temp_id</span>
196
+ <span class='kw'>end</span>
197
+ <span class='kw'>end</span>
198
+ <span class='kw'>end</span></pre>
199
+ </td>
200
+ </tr>
201
+ </table>
202
+ </div>
203
+
204
+ </div>
205
+
206
+ </div>
207
+
208
+ <div id="footer">
209
+ Generated on Fri May 5 15:53:21 2017 by
210
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
211
+ 0.9.9 (ruby-2.3.0).
212
+ </div>
213
+
214
+ </div>
215
+ </body>
216
+ </html>
@@ -0,0 +1,2484 @@
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::Sideload
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::Sideload";
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">Sideload</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::Sideload
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::Sideload</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/sideload.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+
103
+
104
+
105
+
106
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
107
+ <ul class="summary">
108
+
109
+ <li class="public ">
110
+ <span class="summary_signature">
111
+
112
+ <a href="#assign_proc-instance_method" title="#assign_proc (instance method)">#<strong>assign_proc</strong> &#x21d2; Proc </a>
113
+
114
+
115
+
116
+ </span>
117
+
118
+
119
+
120
+
121
+ <span class="note title readonly">readonly</span>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <span class="summary_desc"><div class='inline'>
132
+ <p>The configured &#39;assign&#39; block.</p>
133
+ </div></span>
134
+
135
+ </li>
136
+
137
+
138
+ <li class="public ">
139
+ <span class="summary_signature">
140
+
141
+ <a href="#foreign_key-instance_method" title="#foreign_key (instance method)">#<strong>foreign_key</strong> &#x21d2; Symbol </a>
142
+
143
+
144
+
145
+ </span>
146
+
147
+
148
+
149
+
150
+ <span class="note title readonly">readonly</span>
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+ <span class="summary_desc"><div class='inline'>
161
+ <p>The attribute used to match objects - need not be a true database foreign
162
+ key.</p>
163
+ </div></span>
164
+
165
+ </li>
166
+
167
+
168
+ <li class="public ">
169
+ <span class="summary_signature">
170
+
171
+ <a href="#grouper-instance_method" title="#grouper (instance method)">#<strong>grouper</strong> &#x21d2; Proc </a>
172
+
173
+
174
+
175
+ </span>
176
+
177
+
178
+
179
+
180
+ <span class="note title readonly">readonly</span>
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+ <span class="summary_desc"><div class='inline'>
191
+ <p>The configured &#39;group_by&#39; proc.</p>
192
+ </div></span>
193
+
194
+ </li>
195
+
196
+
197
+ <li class="public ">
198
+ <span class="summary_signature">
199
+
200
+ <a href="#name-instance_method" title="#name (instance method)">#<strong>name</strong> &#x21d2; Symbol </a>
201
+
202
+
203
+
204
+ </span>
205
+
206
+
207
+
208
+
209
+ <span class="note title readonly">readonly</span>
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+ <span class="summary_desc"><div class='inline'>
220
+ <p>The name of the sideload.</p>
221
+ </div></span>
222
+
223
+ </li>
224
+
225
+
226
+ <li class="public ">
227
+ <span class="summary_signature">
228
+
229
+ <a href="#polymorphic-instance_method" title="#polymorphic (instance method)">#<strong>polymorphic</strong> &#x21d2; Boolean </a>
230
+
231
+
232
+
233
+ </span>
234
+
235
+
236
+
237
+
238
+ <span class="note title readonly">readonly</span>
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+ <span class="summary_desc"><div class='inline'>
249
+ <p>Is this a polymorphic sideload?.</p>
250
+ </div></span>
251
+
252
+ </li>
253
+
254
+
255
+ <li class="public ">
256
+ <span class="summary_signature">
257
+
258
+ <a href="#polymorphic_groups-instance_method" title="#polymorphic_groups (instance method)">#<strong>polymorphic_groups</strong> &#x21d2; Hash </a>
259
+
260
+
261
+
262
+ </span>
263
+
264
+
265
+
266
+
267
+ <span class="note title readonly">readonly</span>
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+ <span class="summary_desc"><div class='inline'>
278
+ <p>The subgroups, when polymorphic.</p>
279
+ </div></span>
280
+
281
+ </li>
282
+
283
+
284
+ <li class="public ">
285
+ <span class="summary_signature">
286
+
287
+ <a href="#primary_key-instance_method" title="#primary_key (instance method)">#<strong>primary_key</strong> &#x21d2; Symbol </a>
288
+
289
+
290
+
291
+ </span>
292
+
293
+
294
+
295
+
296
+ <span class="note title readonly">readonly</span>
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+
306
+ <span class="summary_desc"><div class='inline'>
307
+ <p>The attribute used to match objects - need not be a true database primary
308
+ key.</p>
309
+ </div></span>
310
+
311
+ </li>
312
+
313
+
314
+ <li class="public ">
315
+ <span class="summary_signature">
316
+
317
+ <a href="#resource_class-instance_method" title="#resource_class (instance method)">#<strong>resource_class</strong> &#x21d2; Class </a>
318
+
319
+
320
+
321
+ </span>
322
+
323
+
324
+
325
+
326
+ <span class="note title readonly">readonly</span>
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+ <span class="summary_desc"><div class='inline'>
337
+ <p>The corresponding Resource class.</p>
338
+ </div></span>
339
+
340
+ </li>
341
+
342
+
343
+ <li class="public ">
344
+ <span class="summary_signature">
345
+
346
+ <a href="#scope_proc-instance_method" title="#scope_proc (instance method)">#<strong>scope_proc</strong> &#x21d2; Proc </a>
347
+
348
+
349
+
350
+ </span>
351
+
352
+
353
+
354
+
355
+ <span class="note title readonly">readonly</span>
356
+
357
+
358
+
359
+
360
+
361
+
362
+
363
+
364
+
365
+ <span class="summary_desc"><div class='inline'>
366
+ <p>The configured &#39;scope&#39; block.</p>
367
+ </div></span>
368
+
369
+ </li>
370
+
371
+
372
+ <li class="public ">
373
+ <span class="summary_signature">
374
+
375
+ <a href="#sideloads-instance_method" title="#sideloads (instance method)">#<strong>sideloads</strong> &#x21d2; Hash </a>
376
+
377
+
378
+
379
+ </span>
380
+
381
+
382
+
383
+
384
+ <span class="note title readonly">readonly</span>
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+ <span class="summary_desc"><div class='inline'>
395
+ <p>The associated sibling sideloads.</p>
396
+ </div></span>
397
+
398
+ </li>
399
+
400
+
401
+ <li class="public ">
402
+ <span class="summary_signature">
403
+
404
+ <a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong> &#x21d2; Symbol </a>
405
+
406
+
407
+
408
+ </span>
409
+
410
+
411
+
412
+
413
+ <span class="note title readonly">readonly</span>
414
+
415
+
416
+
417
+
418
+
419
+
420
+
421
+
422
+
423
+ <span class="summary_desc"><div class='inline'>
424
+ <p>One of :has_many, :belongs_to, etc.</p>
425
+ </div></span>
426
+
427
+ </li>
428
+
429
+
430
+ </ul>
431
+
432
+
433
+
434
+
435
+
436
+ <h2>
437
+ Instance Method Summary
438
+ <small><a href="#" class="summary_toggle">collapse</a></small>
439
+ </h2>
440
+
441
+ <ul class="summary">
442
+
443
+ <li class="public ">
444
+ <span class="summary_signature">
445
+
446
+ <a href="#allow_sideload-instance_method" title="#allow_sideload (instance method)">#<strong>allow_sideload</strong>(name, opts = {}, &amp;blk) &#x21d2; Object </a>
447
+
448
+
449
+
450
+ </span>
451
+
452
+
453
+
454
+
455
+
456
+
457
+
458
+
459
+
460
+ <span class="summary_desc"><div class='inline'>
461
+ <p>Configure a relationship between Resource objects.</p>
462
+ </div></span>
463
+
464
+ </li>
465
+
466
+
467
+ <li class="public ">
468
+ <span class="summary_signature">
469
+
470
+ <a href="#assign-instance_method" title="#assign (instance method)">#<strong>assign</strong> {|parents, children| ... } &#x21d2; Object </a>
471
+
472
+
473
+
474
+ </span>
475
+
476
+
477
+
478
+
479
+
480
+
481
+
482
+
483
+
484
+ <span class="summary_desc"><div class='inline'>
485
+ <p>The proc used to assign the resolved parents and children.</p>
486
+ </div></span>
487
+
488
+ </li>
489
+
490
+
491
+ <li class="public ">
492
+ <span class="summary_signature">
493
+
494
+ <a href="#associate-instance_method" title="#associate (instance method)">#<strong>associate</strong>(parent, child) &#x21d2; Object </a>
495
+
496
+
497
+
498
+ </span>
499
+
500
+
501
+
502
+
503
+
504
+
505
+
506
+
507
+
508
+ <span class="summary_desc"><div class='inline'>
509
+ <p>Configure how to associate parent and child records.</p>
510
+ </div></span>
511
+
512
+ </li>
513
+
514
+
515
+ <li class="public ">
516
+ <span class="summary_signature">
517
+
518
+ <a href="#group_by-instance_method" title="#group_by (instance method)">#<strong>group_by</strong>(&amp;grouper) &#x21d2; Object </a>
519
+
520
+
521
+
522
+ </span>
523
+
524
+
525
+
526
+
527
+
528
+
529
+
530
+
531
+
532
+ <span class="summary_desc"><div class='inline'>
533
+ <p>Define a proc that groups the parent records.</p>
534
+ </div></span>
535
+
536
+ </li>
537
+
538
+
539
+ <li class="public ">
540
+ <span class="summary_signature">
541
+
542
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(name, type: nil, resource: nil, polymorphic: false, primary_key: :id, foreign_key: nil) &#x21d2; Sideload </a>
543
+
544
+
545
+
546
+ </span>
547
+
548
+
549
+ <span class="note title constructor">constructor</span>
550
+
551
+
552
+
553
+
554
+
555
+
556
+
557
+
558
+ <span class="summary_desc"><div class='inline'>
559
+ <p>NB - the adapter&#39;s <code>#sideloading_module</code> is mixed in on
560
+ instantiation.</p>
561
+ </div></span>
562
+
563
+ </li>
564
+
565
+
566
+ <li class="public ">
567
+ <span class="summary_signature">
568
+
569
+ <a href="#polymorphic%3F-instance_method" title="#polymorphic? (instance method)">#<strong>polymorphic?</strong> &#x21d2; Boolean </a>
570
+
571
+
572
+
573
+ </span>
574
+
575
+
576
+
577
+
578
+
579
+
580
+
581
+
582
+
583
+ <span class="summary_desc"><div class='inline'>
584
+ <p>Is this sideload polymorphic?.</p>
585
+ </div></span>
586
+
587
+ </li>
588
+
589
+
590
+ <li class="public ">
591
+ <span class="summary_signature">
592
+
593
+ <a href="#resolve-instance_method" title="#resolve (instance method)">#<strong>resolve</strong>(parents, query, namespace = nil) &#x21d2; void </a>
594
+
595
+
596
+
597
+ </span>
598
+
599
+
600
+
601
+
602
+
603
+
604
+ <span class="private note title">private</span>
605
+
606
+
607
+ <span class="summary_desc"><div class='inline'>
608
+ <p>Resolve the sideload.</p>
609
+ </div></span>
610
+
611
+ </li>
612
+
613
+
614
+ <li class="public ">
615
+ <span class="summary_signature">
616
+
617
+ <a href="#resource-instance_method" title="#resource (instance method)">#<strong>resource</strong> &#x21d2; Resource </a>
618
+
619
+
620
+
621
+ </span>
622
+
623
+
624
+
625
+
626
+
627
+
628
+
629
+
630
+
631
+ <span class="summary_desc"><div class='inline'>
632
+ <p>An instance of <code>#resource_class</code>.</p>
633
+ </div></span>
634
+
635
+ </li>
636
+
637
+
638
+ <li class="public ">
639
+ <span class="summary_signature">
640
+
641
+ <a href="#scope-instance_method" title="#scope (instance method)">#<strong>scope</strong> {|parents| ... } &#x21d2; Object </a>
642
+
643
+
644
+
645
+ </span>
646
+
647
+
648
+
649
+
650
+
651
+
652
+
653
+
654
+
655
+ <span class="summary_desc"><div class='inline'>
656
+ <p>Build a scope that will be used to fetch the related records This scope
657
+ will be further chained with filtering/sorting/etc.</p>
658
+ </div></span>
659
+
660
+ </li>
661
+
662
+
663
+ <li class="public ">
664
+ <span class="summary_signature">
665
+
666
+ <a href="#sideload-instance_method" title="#sideload (instance method)">#<strong>sideload</strong>(name) &#x21d2; Object </a>
667
+
668
+
669
+
670
+ </span>
671
+
672
+
673
+
674
+
675
+
676
+
677
+
678
+
679
+
680
+ <span class="summary_desc"><div class='inline'>
681
+ <p>Fetch a Sideload object by its name.</p>
682
+ </div></span>
683
+
684
+ </li>
685
+
686
+
687
+ <li class="public ">
688
+ <span class="summary_signature">
689
+
690
+ <a href="#to_hash-instance_method" title="#to_hash (instance method)">#<strong>to_hash</strong>(processed = []) &#x21d2; Hash </a>
691
+
692
+
693
+
694
+ </span>
695
+
696
+
697
+
698
+
699
+
700
+
701
+ <span class="private note title">private</span>
702
+
703
+
704
+ <span class="summary_desc"><div class='inline'>
705
+ <p>Looks at all nested sideload, and all nested sideloads for the
706
+ corresponding Resources, and returns an Include Directive hash.</p>
707
+ </div></span>
708
+
709
+ </li>
710
+
711
+
712
+ </ul>
713
+
714
+
715
+ <div id="constructor_details" class="method_details_list">
716
+ <h2>Constructor Details</h2>
717
+
718
+ <div class="method_details first">
719
+ <h3 class="signature first" id="initialize-instance_method">
720
+
721
+ #<strong>initialize</strong>(name, type: nil, resource: nil, polymorphic: false, primary_key: :id, foreign_key: nil) &#x21d2; <tt><span class='object_link'><a href="" title="JsonapiCompliable::Sideload (class)">Sideload</a></span></tt>
722
+
723
+
724
+
725
+
726
+
727
+ </h3><div class="docstring">
728
+ <div class="discussion">
729
+
730
+ <p>NB - the adapter&#39;s <code>#sideloading_module</code> is mixed in on
731
+ instantiation</p>
732
+
733
+ <p>An anonymous Resource will be assigned when none provided.</p>
734
+
735
+
736
+ </div>
737
+ </div>
738
+ <div class="tags">
739
+
740
+
741
+ <p class="tag_title">See Also:</p>
742
+ <ul class="see">
743
+
744
+ <li><span class='object_link'><a href="Adapters/Abstract.html#sideloading_module-instance_method" title="JsonapiCompliable::Adapters::Abstract#sideloading_module (method)">Adapters::Abstract#sideloading_module</a></span></li>
745
+
746
+ </ul>
747
+
748
+ </div><table class="source_code">
749
+ <tr>
750
+ <td>
751
+ <pre class="lines">
752
+
753
+
754
+ 31
755
+ 32
756
+ 33
757
+ 34
758
+ 35
759
+ 36
760
+ 37
761
+ 38
762
+ 39
763
+ 40
764
+ 41
765
+ 42</pre>
766
+ </td>
767
+ <td>
768
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 31</span>
769
+
770
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>polymorphic:</span> <span class='kw'>false</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='label'>foreign_key:</span> <span class='kw'>nil</span><span class='rparen'>)</span>
771
+ <span class='ivar'>@name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span>
772
+ <span class='ivar'>@resource_class</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span> <span class='op'>||</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></span><span class='rparen'>)</span><span class='rparen'>)</span>
773
+ <span class='ivar'>@sideloads</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
774
+ <span class='ivar'>@polymorphic</span> <span class='op'>=</span> <span class='op'>!</span><span class='op'>!</span><span class='id identifier rubyid_polymorphic'>polymorphic</span>
775
+ <span class='ivar'>@polymorphic_groups</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_polymorphic?'>polymorphic?</span>
776
+ <span class='ivar'>@primary_key</span> <span class='op'>=</span> <span class='id identifier rubyid_primary_key'>primary_key</span>
777
+ <span class='ivar'>@foreign_key</span> <span class='op'>=</span> <span class='id identifier rubyid_foreign_key'>foreign_key</span>
778
+ <span class='ivar'>@type</span> <span class='op'>=</span> <span class='id identifier rubyid_type'>type</span>
779
+
780
+ <span class='id identifier rubyid_extend'>extend</span> <span class='ivar'>@resource_class</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:adapter</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_sideloading_module'>sideloading_module</span>
781
+ <span class='kw'>end</span></pre>
782
+ </td>
783
+ </tr>
784
+ </table>
785
+ </div>
786
+
787
+ </div>
788
+
789
+ <div id="instance_attr_details" class="attr_details">
790
+ <h2>Instance Attribute Details</h2>
791
+
792
+
793
+ <span id=""></span>
794
+ <div class="method_details first">
795
+ <h3 class="signature first" id="assign_proc-instance_method">
796
+
797
+ #<strong>assign_proc</strong> &#x21d2; <tt>Proc</tt> <span class="extras">(readonly)</span>
798
+
799
+
800
+
801
+
802
+
803
+ </h3><div class="docstring">
804
+ <div class="discussion">
805
+
806
+ <p>The configured &#39;assign&#39; block</p>
807
+
808
+
809
+ </div>
810
+ </div>
811
+ <div class="tags">
812
+
813
+ <p class="tag_title">Returns:</p>
814
+ <ul class="return">
815
+
816
+ <li>
817
+
818
+
819
+ <span class='type'>(<tt>Proc</tt>)</span>
820
+
821
+
822
+
823
+ &mdash;
824
+ <div class='inline'>
825
+ <p>the current value of assign_proc</p>
826
+ </div>
827
+
828
+ </li>
829
+
830
+ </ul>
831
+
832
+ </div><table class="source_code">
833
+ <tr>
834
+ <td>
835
+ <pre class="lines">
836
+
837
+
838
+ 13
839
+ 14
840
+ 15</pre>
841
+ </td>
842
+ <td>
843
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
844
+
845
+ <span class='kw'>def</span> <span class='id identifier rubyid_assign_proc'>assign_proc</span>
846
+ <span class='ivar'>@assign_proc</span>
847
+ <span class='kw'>end</span></pre>
848
+ </td>
849
+ </tr>
850
+ </table>
851
+ </div>
852
+
853
+
854
+ <span id=""></span>
855
+ <div class="method_details ">
856
+ <h3 class="signature " id="foreign_key-instance_method">
857
+
858
+ #<strong>foreign_key</strong> &#x21d2; <tt>Symbol</tt> <span class="extras">(readonly)</span>
859
+
860
+
861
+
862
+
863
+
864
+ </h3><div class="docstring">
865
+ <div class="discussion">
866
+
867
+ <p>The attribute used to match objects - need not be a true database foreign
868
+ key.</p>
869
+
870
+
871
+ </div>
872
+ </div>
873
+ <div class="tags">
874
+
875
+ <p class="tag_title">Returns:</p>
876
+ <ul class="return">
877
+
878
+ <li>
879
+
880
+
881
+ <span class='type'>(<tt>Symbol</tt>)</span>
882
+
883
+
884
+
885
+ &mdash;
886
+ <div class='inline'>
887
+ <p>the current value of foreign_key</p>
888
+ </div>
889
+
890
+ </li>
891
+
892
+ </ul>
893
+
894
+ </div><table class="source_code">
895
+ <tr>
896
+ <td>
897
+ <pre class="lines">
898
+
899
+
900
+ 13
901
+ 14
902
+ 15</pre>
903
+ </td>
904
+ <td>
905
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
906
+
907
+ <span class='kw'>def</span> <span class='id identifier rubyid_foreign_key'>foreign_key</span>
908
+ <span class='ivar'>@foreign_key</span>
909
+ <span class='kw'>end</span></pre>
910
+ </td>
911
+ </tr>
912
+ </table>
913
+ </div>
914
+
915
+
916
+ <span id=""></span>
917
+ <div class="method_details ">
918
+ <h3 class="signature " id="grouper-instance_method">
919
+
920
+ #<strong>grouper</strong> &#x21d2; <tt>Proc</tt> <span class="extras">(readonly)</span>
921
+
922
+
923
+
924
+
925
+
926
+ </h3><div class="docstring">
927
+ <div class="discussion">
928
+
929
+ <p>The configured &#39;group_by&#39; proc</p>
930
+
931
+
932
+ </div>
933
+ </div>
934
+ <div class="tags">
935
+
936
+ <p class="tag_title">Returns:</p>
937
+ <ul class="return">
938
+
939
+ <li>
940
+
941
+
942
+ <span class='type'>(<tt>Proc</tt>)</span>
943
+
944
+
945
+
946
+ &mdash;
947
+ <div class='inline'>
948
+ <p>the current value of grouper</p>
949
+ </div>
950
+
951
+ </li>
952
+
953
+ </ul>
954
+
955
+ </div><table class="source_code">
956
+ <tr>
957
+ <td>
958
+ <pre class="lines">
959
+
960
+
961
+ 13
962
+ 14
963
+ 15</pre>
964
+ </td>
965
+ <td>
966
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
967
+
968
+ <span class='kw'>def</span> <span class='id identifier rubyid_grouper'>grouper</span>
969
+ <span class='ivar'>@grouper</span>
970
+ <span class='kw'>end</span></pre>
971
+ </td>
972
+ </tr>
973
+ </table>
974
+ </div>
975
+
976
+
977
+ <span id=""></span>
978
+ <div class="method_details ">
979
+ <h3 class="signature " id="name-instance_method">
980
+
981
+ #<strong>name</strong> &#x21d2; <tt>Symbol</tt> <span class="extras">(readonly)</span>
982
+
983
+
984
+
985
+
986
+
987
+ </h3><div class="docstring">
988
+ <div class="discussion">
989
+
990
+ <p>The name of the sideload</p>
991
+
992
+
993
+ </div>
994
+ </div>
995
+ <div class="tags">
996
+
997
+ <p class="tag_title">Returns:</p>
998
+ <ul class="return">
999
+
1000
+ <li>
1001
+
1002
+
1003
+ <span class='type'>(<tt>Symbol</tt>)</span>
1004
+
1005
+
1006
+
1007
+ &mdash;
1008
+ <div class='inline'>
1009
+ <p>the current value of name</p>
1010
+ </div>
1011
+
1012
+ </li>
1013
+
1014
+ </ul>
1015
+
1016
+ </div><table class="source_code">
1017
+ <tr>
1018
+ <td>
1019
+ <pre class="lines">
1020
+
1021
+
1022
+ 13
1023
+ 14
1024
+ 15</pre>
1025
+ </td>
1026
+ <td>
1027
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1028
+
1029
+ <span class='kw'>def</span> <span class='id identifier rubyid_name'>name</span>
1030
+ <span class='ivar'>@name</span>
1031
+ <span class='kw'>end</span></pre>
1032
+ </td>
1033
+ </tr>
1034
+ </table>
1035
+ </div>
1036
+
1037
+
1038
+ <span id=""></span>
1039
+ <div class="method_details ">
1040
+ <h3 class="signature " id="polymorphic-instance_method">
1041
+
1042
+ #<strong>polymorphic</strong> &#x21d2; <tt>Boolean</tt> <span class="extras">(readonly)</span>
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+ </h3><div class="docstring">
1049
+ <div class="discussion">
1050
+
1051
+ <p>Is this a polymorphic sideload?</p>
1052
+
1053
+
1054
+ </div>
1055
+ </div>
1056
+ <div class="tags">
1057
+
1058
+ <p class="tag_title">Returns:</p>
1059
+ <ul class="return">
1060
+
1061
+ <li>
1062
+
1063
+
1064
+ <span class='type'>(<tt>Boolean</tt>)</span>
1065
+
1066
+
1067
+
1068
+ &mdash;
1069
+ <div class='inline'>
1070
+ <p>the current value of polymorphic</p>
1071
+ </div>
1072
+
1073
+ </li>
1074
+
1075
+ </ul>
1076
+
1077
+ </div><table class="source_code">
1078
+ <tr>
1079
+ <td>
1080
+ <pre class="lines">
1081
+
1082
+
1083
+ 13
1084
+ 14
1085
+ 15</pre>
1086
+ </td>
1087
+ <td>
1088
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1089
+
1090
+ <span class='kw'>def</span> <span class='id identifier rubyid_polymorphic'>polymorphic</span>
1091
+ <span class='ivar'>@polymorphic</span>
1092
+ <span class='kw'>end</span></pre>
1093
+ </td>
1094
+ </tr>
1095
+ </table>
1096
+ </div>
1097
+
1098
+
1099
+ <span id=""></span>
1100
+ <div class="method_details ">
1101
+ <h3 class="signature " id="polymorphic_groups-instance_method">
1102
+
1103
+ #<strong>polymorphic_groups</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
1104
+
1105
+
1106
+
1107
+
1108
+
1109
+ </h3><div class="docstring">
1110
+ <div class="discussion">
1111
+
1112
+ <p>The subgroups, when polymorphic</p>
1113
+
1114
+
1115
+ </div>
1116
+ </div>
1117
+ <div class="tags">
1118
+
1119
+ <p class="tag_title">Returns:</p>
1120
+ <ul class="return">
1121
+
1122
+ <li>
1123
+
1124
+
1125
+ <span class='type'>(<tt>Hash</tt>)</span>
1126
+
1127
+
1128
+
1129
+ &mdash;
1130
+ <div class='inline'>
1131
+ <p>the current value of polymorphic_groups</p>
1132
+ </div>
1133
+
1134
+ </li>
1135
+
1136
+ </ul>
1137
+
1138
+ </div><table class="source_code">
1139
+ <tr>
1140
+ <td>
1141
+ <pre class="lines">
1142
+
1143
+
1144
+ 13
1145
+ 14
1146
+ 15</pre>
1147
+ </td>
1148
+ <td>
1149
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1150
+
1151
+ <span class='kw'>def</span> <span class='id identifier rubyid_polymorphic_groups'>polymorphic_groups</span>
1152
+ <span class='ivar'>@polymorphic_groups</span>
1153
+ <span class='kw'>end</span></pre>
1154
+ </td>
1155
+ </tr>
1156
+ </table>
1157
+ </div>
1158
+
1159
+
1160
+ <span id=""></span>
1161
+ <div class="method_details ">
1162
+ <h3 class="signature " id="primary_key-instance_method">
1163
+
1164
+ #<strong>primary_key</strong> &#x21d2; <tt>Symbol</tt> <span class="extras">(readonly)</span>
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+ </h3><div class="docstring">
1171
+ <div class="discussion">
1172
+
1173
+ <p>The attribute used to match objects - need not be a true database primary
1174
+ key.</p>
1175
+
1176
+
1177
+ </div>
1178
+ </div>
1179
+ <div class="tags">
1180
+
1181
+ <p class="tag_title">Returns:</p>
1182
+ <ul class="return">
1183
+
1184
+ <li>
1185
+
1186
+
1187
+ <span class='type'>(<tt>Symbol</tt>)</span>
1188
+
1189
+
1190
+
1191
+ &mdash;
1192
+ <div class='inline'>
1193
+ <p>the current value of primary_key</p>
1194
+ </div>
1195
+
1196
+ </li>
1197
+
1198
+ </ul>
1199
+
1200
+ </div><table class="source_code">
1201
+ <tr>
1202
+ <td>
1203
+ <pre class="lines">
1204
+
1205
+
1206
+ 13
1207
+ 14
1208
+ 15</pre>
1209
+ </td>
1210
+ <td>
1211
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1212
+
1213
+ <span class='kw'>def</span> <span class='id identifier rubyid_primary_key'>primary_key</span>
1214
+ <span class='ivar'>@primary_key</span>
1215
+ <span class='kw'>end</span></pre>
1216
+ </td>
1217
+ </tr>
1218
+ </table>
1219
+ </div>
1220
+
1221
+
1222
+ <span id=""></span>
1223
+ <div class="method_details ">
1224
+ <h3 class="signature " id="resource_class-instance_method">
1225
+
1226
+ #<strong>resource_class</strong> &#x21d2; <tt>Class</tt> <span class="extras">(readonly)</span>
1227
+
1228
+
1229
+
1230
+
1231
+
1232
+ </h3><div class="docstring">
1233
+ <div class="discussion">
1234
+
1235
+ <p>The corresponding Resource class</p>
1236
+
1237
+
1238
+ </div>
1239
+ </div>
1240
+ <div class="tags">
1241
+
1242
+ <p class="tag_title">Returns:</p>
1243
+ <ul class="return">
1244
+
1245
+ <li>
1246
+
1247
+
1248
+ <span class='type'>(<tt>Class</tt>)</span>
1249
+
1250
+
1251
+
1252
+ &mdash;
1253
+ <div class='inline'>
1254
+ <p>the current value of resource_class</p>
1255
+ </div>
1256
+
1257
+ </li>
1258
+
1259
+ </ul>
1260
+
1261
+ </div><table class="source_code">
1262
+ <tr>
1263
+ <td>
1264
+ <pre class="lines">
1265
+
1266
+
1267
+ 13
1268
+ 14
1269
+ 15</pre>
1270
+ </td>
1271
+ <td>
1272
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1273
+
1274
+ <span class='kw'>def</span> <span class='id identifier rubyid_resource_class'>resource_class</span>
1275
+ <span class='ivar'>@resource_class</span>
1276
+ <span class='kw'>end</span></pre>
1277
+ </td>
1278
+ </tr>
1279
+ </table>
1280
+ </div>
1281
+
1282
+
1283
+ <span id=""></span>
1284
+ <div class="method_details ">
1285
+ <h3 class="signature " id="scope_proc-instance_method">
1286
+
1287
+ #<strong>scope_proc</strong> &#x21d2; <tt>Proc</tt> <span class="extras">(readonly)</span>
1288
+
1289
+
1290
+
1291
+
1292
+
1293
+ </h3><div class="docstring">
1294
+ <div class="discussion">
1295
+
1296
+ <p>The configured &#39;scope&#39; block</p>
1297
+
1298
+
1299
+ </div>
1300
+ </div>
1301
+ <div class="tags">
1302
+
1303
+ <p class="tag_title">Returns:</p>
1304
+ <ul class="return">
1305
+
1306
+ <li>
1307
+
1308
+
1309
+ <span class='type'>(<tt>Proc</tt>)</span>
1310
+
1311
+
1312
+
1313
+ &mdash;
1314
+ <div class='inline'>
1315
+ <p>the current value of scope_proc</p>
1316
+ </div>
1317
+
1318
+ </li>
1319
+
1320
+ </ul>
1321
+
1322
+ </div><table class="source_code">
1323
+ <tr>
1324
+ <td>
1325
+ <pre class="lines">
1326
+
1327
+
1328
+ 13
1329
+ 14
1330
+ 15</pre>
1331
+ </td>
1332
+ <td>
1333
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1334
+
1335
+ <span class='kw'>def</span> <span class='id identifier rubyid_scope_proc'>scope_proc</span>
1336
+ <span class='ivar'>@scope_proc</span>
1337
+ <span class='kw'>end</span></pre>
1338
+ </td>
1339
+ </tr>
1340
+ </table>
1341
+ </div>
1342
+
1343
+
1344
+ <span id=""></span>
1345
+ <div class="method_details ">
1346
+ <h3 class="signature " id="sideloads-instance_method">
1347
+
1348
+ #<strong>sideloads</strong> &#x21d2; <tt>Hash</tt> <span class="extras">(readonly)</span>
1349
+
1350
+
1351
+
1352
+
1353
+
1354
+ </h3><div class="docstring">
1355
+ <div class="discussion">
1356
+
1357
+ <p>The associated sibling sideloads</p>
1358
+
1359
+
1360
+ </div>
1361
+ </div>
1362
+ <div class="tags">
1363
+
1364
+ <p class="tag_title">Returns:</p>
1365
+ <ul class="return">
1366
+
1367
+ <li>
1368
+
1369
+
1370
+ <span class='type'>(<tt>Hash</tt>)</span>
1371
+
1372
+
1373
+
1374
+ &mdash;
1375
+ <div class='inline'>
1376
+ <p>the current value of sideloads</p>
1377
+ </div>
1378
+
1379
+ </li>
1380
+
1381
+ </ul>
1382
+
1383
+ </div><table class="source_code">
1384
+ <tr>
1385
+ <td>
1386
+ <pre class="lines">
1387
+
1388
+
1389
+ 13
1390
+ 14
1391
+ 15</pre>
1392
+ </td>
1393
+ <td>
1394
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1395
+
1396
+ <span class='kw'>def</span> <span class='id identifier rubyid_sideloads'>sideloads</span>
1397
+ <span class='ivar'>@sideloads</span>
1398
+ <span class='kw'>end</span></pre>
1399
+ </td>
1400
+ </tr>
1401
+ </table>
1402
+ </div>
1403
+
1404
+
1405
+ <span id=""></span>
1406
+ <div class="method_details ">
1407
+ <h3 class="signature " id="type-instance_method">
1408
+
1409
+ #<strong>type</strong> &#x21d2; <tt>Symbol</tt> <span class="extras">(readonly)</span>
1410
+
1411
+
1412
+
1413
+
1414
+
1415
+ </h3><div class="docstring">
1416
+ <div class="discussion">
1417
+
1418
+ <p>One of :has_many, :belongs_to, etc</p>
1419
+
1420
+
1421
+ </div>
1422
+ </div>
1423
+ <div class="tags">
1424
+
1425
+ <p class="tag_title">Returns:</p>
1426
+ <ul class="return">
1427
+
1428
+ <li>
1429
+
1430
+
1431
+ <span class='type'>(<tt>Symbol</tt>)</span>
1432
+
1433
+
1434
+
1435
+ &mdash;
1436
+ <div class='inline'>
1437
+ <p>the current value of type</p>
1438
+ </div>
1439
+
1440
+ </li>
1441
+
1442
+ </ul>
1443
+
1444
+ </div><table class="source_code">
1445
+ <tr>
1446
+ <td>
1447
+ <pre class="lines">
1448
+
1449
+
1450
+ 13
1451
+ 14
1452
+ 15</pre>
1453
+ </td>
1454
+ <td>
1455
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 13</span>
1456
+
1457
+ <span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span>
1458
+ <span class='ivar'>@type</span>
1459
+ <span class='kw'>end</span></pre>
1460
+ </td>
1461
+ </tr>
1462
+ </table>
1463
+ </div>
1464
+
1465
+ </div>
1466
+
1467
+
1468
+ <div id="instance_method_details" class="method_details_list">
1469
+ <h2>Instance Method Details</h2>
1470
+
1471
+
1472
+ <div class="method_details first">
1473
+ <h3 class="signature first" id="allow_sideload-instance_method">
1474
+
1475
+ #<strong>allow_sideload</strong>(name, opts = {}, &amp;blk) &#x21d2; <tt>Object</tt>
1476
+
1477
+
1478
+
1479
+
1480
+
1481
+ </h3><div class="docstring">
1482
+ <div class="discussion">
1483
+
1484
+ <p>Configure a relationship between Resource objects</p>
1485
+
1486
+ <p>You probably want to extract this logic into an adapter rather than using
1487
+ directly</p>
1488
+
1489
+
1490
+ </div>
1491
+ </div>
1492
+ <div class="tags">
1493
+
1494
+ <div class="examples">
1495
+ <p class="tag_title">Examples:</p>
1496
+
1497
+
1498
+ <p class="example_title"><div class='inline'>
1499
+ <p>Default ActiveRecord</p>
1500
+ </div></p>
1501
+
1502
+ <pre class="example code"><code><span class='comment'># What happens &#39;under the hood&#39;
1503
+ </span><span class='kw'>class</span> <span class='const'>CommentResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
1504
+ <span class='comment'># ... code ...
1505
+ </span> <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:post</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='const'>PostResource</span> <span class='kw'>do</span>
1506
+ <span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_comments'>comments</span><span class='op'>|</span>
1507
+ <span class='const'>Post</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>id:</span> <span class='id identifier rubyid_comments'>comments</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:post_id</span><span class='rparen'>)</span><span class='rparen'>)</span>
1508
+ <span class='kw'>end</span>
1509
+
1510
+ <span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_comments'>comments</span><span class='comma'>,</span> <span class='id identifier rubyid_posts'>posts</span><span class='op'>|</span>
1511
+ <span class='id identifier rubyid_comments'>comments</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_comment'>comment</span><span class='op'>|</span>
1512
+ <span class='id identifier rubyid_relevant_post'>relevant_post</span> <span class='op'>=</span> <span class='id identifier rubyid_posts'>posts</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_p'>p</span><span class='op'>|</span> <span class='id identifier rubyid_p'>p</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='op'>==</span> <span class='id identifier rubyid_comment'>comment</span><span class='period'>.</span><span class='id identifier rubyid_post_id'>post_id</span> <span class='rbrace'>}</span>
1513
+ <span class='id identifier rubyid_comment'>comment</span><span class='period'>.</span><span class='id identifier rubyid_post'>post</span> <span class='op'>=</span> <span class='id identifier rubyid_relevant_post'>relevant_post</span>
1514
+ <span class='kw'>end</span>
1515
+ <span class='kw'>end</span>
1516
+ <span class='kw'>end</span>
1517
+ <span class='kw'>end</span>
1518
+
1519
+ <span class='comment'># Rather than writing that code directly, go through the adapter:
1520
+ </span><span class='kw'>class</span> <span class='const'>CommentResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
1521
+ <span class='comment'># ... code ...
1522
+ </span> <span class='id identifier rubyid_use_adapter'>use_adapter</span> <span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Adapters/ActiveRecord.html" title="JsonapiCompliable::Adapters::ActiveRecord (class)">ActiveRecord</a></span></span>
1523
+
1524
+ <span class='id identifier rubyid_belongs_to'>belongs_to</span> <span class='symbol'>:post</span><span class='comma'>,</span>
1525
+ <span class='label'>scope:</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='const'>Post</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span> <span class='rbrace'>}</span><span class='comma'>,</span>
1526
+ <span class='label'>resource:</span> <span class='const'>PostResource</span><span class='comma'>,</span>
1527
+ <span class='label'>foreign_key:</span> <span class='symbol'>:post_id</span>
1528
+ <span class='kw'>end</span></code></pre>
1529
+
1530
+ </div>
1531
+
1532
+ <p class="tag_title">Returns:</p>
1533
+ <ul class="return">
1534
+
1535
+ <li>
1536
+
1537
+
1538
+ <span class='type'></span>
1539
+
1540
+
1541
+
1542
+
1543
+ <div class='inline'>
1544
+ <p>void</p>
1545
+ </div>
1546
+
1547
+ </li>
1548
+
1549
+ </ul>
1550
+
1551
+ <p class="tag_title">See Also:</p>
1552
+ <ul class="see">
1553
+
1554
+ <li><span class='object_link'><a href="Adapters/ActiveRecordSideloading.html#belongs_to-instance_method" title="JsonapiCompliable::Adapters::ActiveRecordSideloading#belongs_to (method)">Adapters::ActiveRecordSideloading#belongs_to</a></span></li>
1555
+
1556
+ <li><span class='object_link'><a href="#assign-instance_method" title="JsonapiCompliable::Sideload#assign (method)">#assign</a></span></li>
1557
+
1558
+ <li><span class='object_link'><a href="#scope-instance_method" title="JsonapiCompliable::Sideload#scope (method)">#scope</a></span></li>
1559
+
1560
+ </ul>
1561
+
1562
+ </div><table class="source_code">
1563
+ <tr>
1564
+ <td>
1565
+ <pre class="lines">
1566
+
1567
+
1568
+ 264
1569
+ 265
1570
+ 266
1571
+ 267
1572
+ 268
1573
+ 269
1574
+ 270
1575
+ 271
1576
+ 272
1577
+ 273</pre>
1578
+ </td>
1579
+ <td>
1580
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 264</span>
1581
+
1582
+ <span class='kw'>def</span> <span class='id identifier rubyid_allow_sideload'>allow_sideload</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</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='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
1583
+ <span class='id identifier rubyid_sideload'>sideload</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="" title="JsonapiCompliable::Sideload (class)">Sideload</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="#initialize-instance_method" title="JsonapiCompliable::Sideload#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
1584
+ <span class='id identifier rubyid_sideload'>sideload</span><span class='period'>.</span><span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_blk'>blk</span>
1585
+
1586
+ <span class='kw'>if</span> <span class='id identifier rubyid_polymorphic?'>polymorphic?</span>
1587
+ <span class='ivar'>@polymorphic_groups</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sideload'>sideload</span>
1588
+ <span class='kw'>else</span>
1589
+ <span class='ivar'>@sideloads</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sideload'>sideload</span>
1590
+ <span class='kw'>end</span>
1591
+ <span class='kw'>end</span></pre>
1592
+ </td>
1593
+ </tr>
1594
+ </table>
1595
+ </div>
1596
+
1597
+ <div class="method_details ">
1598
+ <h3 class="signature " id="assign-instance_method">
1599
+
1600
+ #<strong>assign</strong> {|parents, children| ... } &#x21d2; <tt>Object</tt>
1601
+
1602
+
1603
+
1604
+
1605
+
1606
+ </h3><div class="docstring">
1607
+ <div class="discussion">
1608
+
1609
+ <p>The proc used to assign the resolved parents and children.</p>
1610
+
1611
+ <p>You probably want to wrap this logic in an Adapter, instead of specifying
1612
+ in your resource directly.</p>
1613
+
1614
+
1615
+ </div>
1616
+ </div>
1617
+ <div class="tags">
1618
+
1619
+ <div class="examples">
1620
+ <p class="tag_title">Examples:</p>
1621
+
1622
+
1623
+ <p class="example_title"><div class='inline'>
1624
+ <p>Default ActiveRecord</p>
1625
+ </div></p>
1626
+
1627
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>PostResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
1628
+ <span class='comment'># ... code ...
1629
+ </span> <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:comments</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='const'>CommentResource</span> <span class='kw'>do</span>
1630
+ <span class='comment'># ... code ...
1631
+ </span> <span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_posts'>posts</span><span class='comma'>,</span> <span class='id identifier rubyid_comments'>comments</span><span class='op'>|</span>
1632
+ <span class='id identifier rubyid_posts'>posts</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_post'>post</span><span class='op'>|</span>
1633
+ <span class='id identifier rubyid_relevant_comments'>relevant_comments</span> <span class='op'>=</span> <span class='id identifier rubyid_comments'>comments</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</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_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_post_id'>post_id</span> <span class='op'>==</span> <span class='id identifier rubyid_post'>post</span><span class='period'>.</span><span class='id identifier rubyid_id'>id</span> <span class='rbrace'>}</span>
1634
+ <span class='id identifier rubyid_post'>post</span><span class='period'>.</span><span class='id identifier rubyid_comments'>comments</span> <span class='op'>=</span> <span class='id identifier rubyid_relevant_comments'>relevant_comments</span>
1635
+ <span class='kw'>end</span>
1636
+ <span class='kw'>end</span>
1637
+ <span class='kw'>end</span>
1638
+ <span class='kw'>end</span></code></pre>
1639
+
1640
+
1641
+ <p class="example_title"><div class='inline'>
1642
+ <p>ActiveRecord via Adapter</p>
1643
+ </div></p>
1644
+
1645
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>PostResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
1646
+ <span class='comment'># ... code ...
1647
+ </span> <span class='id identifier rubyid_has_many'>has_many</span> <span class='symbol'>:comments</span><span class='comma'>,</span>
1648
+ <span class='label'>scope:</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='const'>Comment</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span> <span class='rbrace'>}</span><span class='comma'>,</span>
1649
+ <span class='label'>resource:</span> <span class='const'>CommentResource</span><span class='comma'>,</span>
1650
+ <span class='label'>foreign_key:</span> <span class='symbol'>:post_id</span>
1651
+ <span class='kw'>end</span></code></pre>
1652
+
1653
+ </div>
1654
+
1655
+ <p class="tag_title">Yield Parameters:</p>
1656
+ <ul class="yieldparam">
1657
+
1658
+ <li>
1659
+
1660
+ <span class='name'>parents</span>
1661
+
1662
+
1663
+ <span class='type'></span>
1664
+
1665
+
1666
+
1667
+ &mdash;
1668
+ <div class='inline'><ul><li>
1669
+ <p>The resolved parent records</p>
1670
+ </li></ul>
1671
+ </div>
1672
+
1673
+ </li>
1674
+
1675
+ <li>
1676
+
1677
+ <span class='name'>children</span>
1678
+
1679
+
1680
+ <span class='type'></span>
1681
+
1682
+
1683
+
1684
+ &mdash;
1685
+ <div class='inline'><ul><li>
1686
+ <p>The resolved child records</p>
1687
+ </li></ul>
1688
+ </div>
1689
+
1690
+ </li>
1691
+
1692
+ </ul>
1693
+
1694
+ <p class="tag_title">See Also:</p>
1695
+ <ul class="see">
1696
+
1697
+ <li><span class='object_link'><a href="Adapters/Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Adapters::Abstract</a></span></li>
1698
+
1699
+ <li><span class='object_link'><a href="Adapters/ActiveRecordSideloading.html#has_many-instance_method" title="JsonapiCompliable::Adapters::ActiveRecordSideloading#has_many (method)">Adapters::ActiveRecordSideloading#has_many</a></span></li>
1700
+
1701
+ <li><span class='object_link'><a href="#allow_sideload-instance_method" title="JsonapiCompliable::Sideload#allow_sideload (method)">#allow_sideload</a></span></li>
1702
+
1703
+ </ul>
1704
+
1705
+ </div><table class="source_code">
1706
+ <tr>
1707
+ <td>
1708
+ <pre class="lines">
1709
+
1710
+
1711
+ 166
1712
+ 167
1713
+ 168</pre>
1714
+ </td>
1715
+ <td>
1716
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 166</span>
1717
+
1718
+ <span class='kw'>def</span> <span class='id identifier rubyid_assign'>assign</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
1719
+ <span class='ivar'>@assign_proc</span> <span class='op'>=</span> <span class='id identifier rubyid_blk'>blk</span>
1720
+ <span class='kw'>end</span></pre>
1721
+ </td>
1722
+ </tr>
1723
+ </table>
1724
+ </div>
1725
+
1726
+ <div class="method_details ">
1727
+ <h3 class="signature " id="associate-instance_method">
1728
+
1729
+ #<strong>associate</strong>(parent, child) &#x21d2; <tt>Object</tt>
1730
+
1731
+
1732
+
1733
+
1734
+
1735
+ </h3><div class="docstring">
1736
+ <div class="discussion">
1737
+
1738
+ <p>Configure how to associate parent and child records.</p>
1739
+
1740
+
1741
+ </div>
1742
+ </div>
1743
+ <div class="tags">
1744
+
1745
+ <div class="examples">
1746
+ <p class="tag_title">Examples:</p>
1747
+
1748
+
1749
+ <p class="example_title"><div class='inline'>
1750
+ <p>Basic attr_accessor</p>
1751
+ </div></p>
1752
+
1753
+ <pre class="example code"><code><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='rparen'>)</span>
1754
+ <span class='kw'>if</span> <span class='id identifier rubyid_type'>type</span> <span class='op'>==</span> <span class='symbol'>:has_many</span>
1755
+ <span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='symbol'>:#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span><span class='lparen'>(</span><span class='id identifier rubyid_child'>child</span><span class='rparen'>)</span>
1756
+ <span class='kw'>else</span>
1757
+ <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='symbol'>:#{</span><span class='id identifier rubyid_name'>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>
1758
+ <span class='kw'>end</span>
1759
+ <span class='kw'>end</span></code></pre>
1760
+
1761
+ </div>
1762
+
1763
+
1764
+ <p class="tag_title">See Also:</p>
1765
+ <ul class="see">
1766
+
1767
+ <li><span class='object_link'><a href="#name-instance_method" title="JsonapiCompliable::Sideload#name (method)">#name</a></span></li>
1768
+
1769
+ <li><span class='object_link'><a href="#type-instance_method" title="JsonapiCompliable::Sideload#type (method)">#type</a></span></li>
1770
+
1771
+ </ul>
1772
+
1773
+ </div><table class="source_code">
1774
+ <tr>
1775
+ <td>
1776
+ <pre class="lines">
1777
+
1778
+
1779
+ 183
1780
+ 184
1781
+ 185</pre>
1782
+ </td>
1783
+ <td>
1784
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 183</span>
1785
+
1786
+ <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='rparen'>)</span>
1787
+ <span class='id identifier rubyid_resource_class'>resource_class</span><span class='period'>.</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:adapter</span><span class='rbracket'>]</span><span class='period'>.</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_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
1788
+ <span class='kw'>end</span></pre>
1789
+ </td>
1790
+ </tr>
1791
+ </table>
1792
+ </div>
1793
+
1794
+ <div class="method_details ">
1795
+ <h3 class="signature " id="group_by-instance_method">
1796
+
1797
+ #<strong>group_by</strong>(&amp;grouper) &#x21d2; <tt>Object</tt>
1798
+
1799
+
1800
+
1801
+
1802
+
1803
+ </h3><div class="docstring">
1804
+ <div class="discussion">
1805
+
1806
+ <p>Define a proc that groups the parent records. For instance, with an
1807
+ ActiveRecord polymorphic belongs_to there will be a <code>parent_id</code>
1808
+ and <code>parent_type</code>. We would want to group on
1809
+ <code>parent_type</code>:</p>
1810
+
1811
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:organization</span><span class='comma'>,</span> <span class='label'>polymorphic:</span> <span class='kw'>true</span> <span class='kw'>do</span>
1812
+ <span class='comment'># group parent_type, parent here is &#39;organization&#39;
1813
+ </span> <span class='id identifier rubyid_group_by'>group_by</span> <span class='tlambda'>-&gt;</span><span class='lparen'>(</span><span class='id identifier rubyid_office'>office</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_office'>office</span><span class='period'>.</span><span class='id identifier rubyid_organization_type'>organization_type</span> <span class='rbrace'>}</span>
1814
+ <span class='kw'>end</span>
1815
+ </code></pre>
1816
+
1817
+
1818
+ </div>
1819
+ </div>
1820
+ <div class="tags">
1821
+
1822
+
1823
+ <p class="tag_title">See Also:</p>
1824
+ <ul class="see">
1825
+
1826
+ <li><span class='object_link'><a href="#polymorphic%3F-instance_method" title="JsonapiCompliable::Sideload#polymorphic? (method)">#polymorphic?</a></span></li>
1827
+
1828
+ </ul>
1829
+
1830
+ </div><table class="source_code">
1831
+ <tr>
1832
+ <td>
1833
+ <pre class="lines">
1834
+
1835
+
1836
+ 197
1837
+ 198
1838
+ 199</pre>
1839
+ </td>
1840
+ <td>
1841
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 197</span>
1842
+
1843
+ <span class='kw'>def</span> <span class='id identifier rubyid_group_by'>group_by</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_grouper'>grouper</span><span class='rparen'>)</span>
1844
+ <span class='ivar'>@grouper</span> <span class='op'>=</span> <span class='id identifier rubyid_grouper'>grouper</span>
1845
+ <span class='kw'>end</span></pre>
1846
+ </td>
1847
+ </tr>
1848
+ </table>
1849
+ </div>
1850
+
1851
+ <div class="method_details ">
1852
+ <h3 class="signature " id="polymorphic?-instance_method">
1853
+
1854
+ #<strong>polymorphic?</strong> &#x21d2; <tt>Boolean</tt>
1855
+
1856
+
1857
+
1858
+
1859
+
1860
+ </h3><div class="docstring">
1861
+ <div class="discussion">
1862
+
1863
+ <p>Is this sideload polymorphic?</p>
1864
+
1865
+ <p>Polymorphic sideloads group the parent objects in some fashion, so
1866
+ different &#39;types&#39; can be resolved differently. Let&#39;s say an
1867
+ <code>Office</code> has a polymorphic <code>Organization</code>, which can
1868
+ be either a <code>Business</code> or <code>Government</code>:</p>
1869
+
1870
+ <pre class="code ruby"><code class="ruby">allow_sideload :organization, :polymorphic: true do
1871
+ group_by { |record| record.organization_type }
1872
+
1873
+ allow_sideload &#39;Business&#39;, resource: BusinessResource do
1874
+ # ... code ...
1875
+ end
1876
+
1877
+ allow_sideload &#39;Governemnt&#39;, resource: GovernmentResource do
1878
+ # ... code ...
1879
+ end
1880
+ end</code></pre>
1881
+
1882
+ <p>You probably want to extract this code into an Adapter. For instance, with
1883
+ ActiveRecord:</p>
1884
+
1885
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_polymorphic_belongs_to'>polymorphic_belongs_to</span> <span class='symbol'>:organization</span><span class='comma'>,</span>
1886
+ <span class='label'>group_by:</span> <span class='tlambda'>-&gt;</span><span class='lparen'>(</span><span class='id identifier rubyid_office'>office</span><span class='rparen'>)</span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_office'>office</span><span class='period'>.</span><span class='id identifier rubyid_organization_type'>organization_type</span> <span class='rbrace'>}</span><span class='comma'>,</span>
1887
+ <span class='label'>groups:</span> <span class='lbrace'>{</span>
1888
+ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Business</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
1889
+ <span class='label'>scope:</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='const'>Business</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span> <span class='rbrace'>}</span><span class='comma'>,</span>
1890
+ <span class='label'>resource:</span> <span class='const'>BusinessResource</span><span class='comma'>,</span>
1891
+ <span class='label'>foreign_key:</span> <span class='symbol'>:organization_id</span>
1892
+ <span class='rbrace'>}</span><span class='comma'>,</span>
1893
+ <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Government</span><span class='tstring_end'>&#39;</span></span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span>
1894
+ <span class='label'>scope:</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='const'>Government</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span> <span class='rbrace'>}</span><span class='comma'>,</span>
1895
+ <span class='label'>resource:</span> <span class='const'>GovernmentResource</span><span class='comma'>,</span>
1896
+ <span class='label'>foreign_key:</span> <span class='symbol'>:organization_id</span>
1897
+ <span class='rbrace'>}</span>
1898
+ <span class='rbrace'>}</span>
1899
+ </code></pre>
1900
+
1901
+
1902
+ </div>
1903
+ </div>
1904
+ <div class="tags">
1905
+
1906
+ <p class="tag_title">Returns:</p>
1907
+ <ul class="return">
1908
+
1909
+ <li>
1910
+
1911
+
1912
+ <span class='type'>(<tt>Boolean</tt>)</span>
1913
+
1914
+
1915
+
1916
+ &mdash;
1917
+ <div class='inline'>
1918
+ <p>is this sideload polymorphic?</p>
1919
+ </div>
1920
+
1921
+ </li>
1922
+
1923
+ </ul>
1924
+
1925
+ <p class="tag_title">See Also:</p>
1926
+ <ul class="see">
1927
+
1928
+ <li><span class='object_link'><a href="Adapters/ActiveRecordSideloading.html#polymorphic_belongs_to-instance_method" title="JsonapiCompliable::Adapters::ActiveRecordSideloading#polymorphic_belongs_to (method)">Adapters::ActiveRecordSideloading#polymorphic_belongs_to</a></span></li>
1929
+
1930
+ </ul>
1931
+
1932
+ </div><table class="source_code">
1933
+ <tr>
1934
+ <td>
1935
+ <pre class="lines">
1936
+
1937
+
1938
+ 89
1939
+ 90
1940
+ 91</pre>
1941
+ </td>
1942
+ <td>
1943
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 89</span>
1944
+
1945
+ <span class='kw'>def</span> <span class='id identifier rubyid_polymorphic?'>polymorphic?</span>
1946
+ <span class='ivar'>@polymorphic</span> <span class='op'>==</span> <span class='kw'>true</span>
1947
+ <span class='kw'>end</span></pre>
1948
+ </td>
1949
+ </tr>
1950
+ </table>
1951
+ </div>
1952
+
1953
+ <div class="method_details ">
1954
+ <h3 class="signature " id="resolve-instance_method">
1955
+
1956
+ #<strong>resolve</strong>(parents, query, namespace = nil) &#x21d2; <tt>void</tt>
1957
+
1958
+
1959
+
1960
+
1961
+
1962
+ </h3><div class="docstring">
1963
+ <div class="discussion">
1964
+ <p class="note private">
1965
+ <strong>This method is part of a private API.</strong>
1966
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
1967
+ </p>
1968
+ <p class="note returns_void">This method returns an undefined value.</p>
1969
+ <p>Resolve the sideload.</p>
1970
+ <ul><li>
1971
+ <p>Uses the &#39;scope&#39; proc to build a &#39;base scope&#39;</p>
1972
+ </li><li>
1973
+ <p>Chains additional criteria onto that &#39;base scope&#39;</p>
1974
+ </li><li>
1975
+ <p>Resolves that scope (see Scope#resolve)</p>
1976
+ </li><li>
1977
+ <p>Assigns the resulting child objects to their corresponding parents</p>
1978
+ </li></ul>
1979
+
1980
+
1981
+ </div>
1982
+ </div>
1983
+ <div class="tags">
1984
+ <p class="tag_title">Parameters:</p>
1985
+ <ul class="param">
1986
+
1987
+ <li>
1988
+
1989
+ <span class='name'>parents</span>
1990
+
1991
+
1992
+ <span class='type'>(<tt>Object</tt>)</span>
1993
+
1994
+
1995
+
1996
+ &mdash;
1997
+ <div class='inline'>
1998
+ <p>The resolved parent models</p>
1999
+ </div>
2000
+
2001
+ </li>
2002
+
2003
+ <li>
2004
+
2005
+ <span class='name'>query</span>
2006
+
2007
+
2008
+ <span class='type'>(<tt><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></tt>)</span>
2009
+
2010
+
2011
+
2012
+ &mdash;
2013
+ <div class='inline'>
2014
+ <p>The Query instance</p>
2015
+ </div>
2016
+
2017
+ </li>
2018
+
2019
+ <li>
2020
+
2021
+ <span class='name'>namespace</span>
2022
+
2023
+
2024
+ <span class='type'>(<tt>Symbol</tt>)</span>
2025
+
2026
+
2027
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
2028
+
2029
+
2030
+ &mdash;
2031
+ <div class='inline'>
2032
+ <p>The current namespace (see Resource#with_context)</p>
2033
+ </div>
2034
+
2035
+ </li>
2036
+
2037
+ </ul>
2038
+
2039
+
2040
+ <p class="tag_title">See Also:</p>
2041
+ <ul class="see">
2042
+
2043
+ <li><span class='object_link'><a href="Scope.html#resolve-instance_method" title="JsonapiCompliable::Scope#resolve (method)">JsonapiCompliable::Scope#resolve</a></span></li>
2044
+
2045
+ <li><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></li>
2046
+
2047
+ <li><span class='object_link'><a href="Resource.html#with_context-instance_method" title="JsonapiCompliable::Resource#with_context (method)">Resource#with_context</a></span></li>
2048
+
2049
+ </ul>
2050
+
2051
+ </div><table class="source_code">
2052
+ <tr>
2053
+ <td>
2054
+ <pre class="lines">
2055
+
2056
+
2057
+ 216
2058
+ 217
2059
+ 218
2060
+ 219
2061
+ 220
2062
+ 221
2063
+ 222
2064
+ 223
2065
+ 224</pre>
2066
+ </td>
2067
+ <td>
2068
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 216</span>
2069
+
2070
+ <span class='kw'>def</span> <span class='id identifier rubyid_resolve'>resolve</span><span class='lparen'>(</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_namespace'>namespace</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
2071
+ <span class='id identifier rubyid_namespace'>namespace</span> <span class='op'>||=</span> <span class='id identifier rubyid_name'>name</span>
2072
+
2073
+ <span class='kw'>if</span> <span class='id identifier rubyid_polymorphic?'>polymorphic?</span>
2074
+ <span class='id identifier rubyid_resolve_polymorphic'>resolve_polymorphic</span><span class='lparen'>(</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='rparen'>)</span>
2075
+ <span class='kw'>else</span>
2076
+ <span class='id identifier rubyid_resolve_basic'>resolve_basic</span><span class='lparen'>(</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_namespace'>namespace</span><span class='rparen'>)</span>
2077
+ <span class='kw'>end</span>
2078
+ <span class='kw'>end</span></pre>
2079
+ </td>
2080
+ </tr>
2081
+ </table>
2082
+ </div>
2083
+
2084
+ <div class="method_details ">
2085
+ <h3 class="signature " id="resource-instance_method">
2086
+
2087
+ #<strong>resource</strong> &#x21d2; <tt><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></tt>
2088
+
2089
+
2090
+
2091
+
2092
+
2093
+ </h3><div class="docstring">
2094
+ <div class="discussion">
2095
+
2096
+ <p>Returns an instance of <code>#resource_class</code></p>
2097
+
2098
+
2099
+ </div>
2100
+ </div>
2101
+ <div class="tags">
2102
+
2103
+ <p class="tag_title">Returns:</p>
2104
+ <ul class="return">
2105
+
2106
+ <li>
2107
+
2108
+
2109
+ <span class='type'>(<tt><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></tt>)</span>
2110
+
2111
+
2112
+
2113
+ &mdash;
2114
+ <div class='inline'>
2115
+ <p>an instance of <code>#resource_class</code></p>
2116
+ </div>
2117
+
2118
+ </li>
2119
+
2120
+ </ul>
2121
+
2122
+ <p class="tag_title">See Also:</p>
2123
+ <ul class="see">
2124
+
2125
+ <li><span class='object_link'><a href="#resource_class-instance_method" title="JsonapiCompliable::Sideload#resource_class (method)">#resource_class</a></span></li>
2126
+
2127
+ </ul>
2128
+
2129
+ </div><table class="source_code">
2130
+ <tr>
2131
+ <td>
2132
+ <pre class="lines">
2133
+
2134
+
2135
+ 46
2136
+ 47
2137
+ 48</pre>
2138
+ </td>
2139
+ <td>
2140
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 46</span>
2141
+
2142
+ <span class='kw'>def</span> <span class='id identifier rubyid_resource'>resource</span>
2143
+ <span class='ivar'>@resource</span> <span class='op'>||=</span> <span class='id identifier rubyid_resource_class'>resource_class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
2144
+ <span class='kw'>end</span></pre>
2145
+ </td>
2146
+ </tr>
2147
+ </table>
2148
+ </div>
2149
+
2150
+ <div class="method_details ">
2151
+ <h3 class="signature " id="scope-instance_method">
2152
+
2153
+ #<strong>scope</strong> {|parents| ... } &#x21d2; <tt>Object</tt>
2154
+
2155
+
2156
+
2157
+
2158
+
2159
+ </h3><div class="docstring">
2160
+ <div class="discussion">
2161
+
2162
+ <p>Build a scope that will be used to fetch the related records This scope
2163
+ will be further chained with filtering/sorting/etc</p>
2164
+
2165
+ <p>You probably want to wrap this logic in an Adapter, instead of specifying
2166
+ in your resource directly.</p>
2167
+
2168
+
2169
+ </div>
2170
+ </div>
2171
+ <div class="tags">
2172
+
2173
+ <div class="examples">
2174
+ <p class="tag_title">Examples:</p>
2175
+
2176
+
2177
+ <p class="example_title"><div class='inline'>
2178
+ <p>Default ActiveRecord</p>
2179
+ </div></p>
2180
+
2181
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>PostResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
2182
+ <span class='comment'># ... code ...
2183
+ </span> <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:comments</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='const'>CommentResource</span> <span class='kw'>do</span>
2184
+ <span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_posts'>posts</span><span class='op'>|</span>
2185
+ <span class='const'>Comment</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='label'>post_id:</span> <span class='id identifier rubyid_posts'>posts</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:id</span><span class='rparen'>)</span><span class='rparen'>)</span>
2186
+ <span class='kw'>end</span>
2187
+ <span class='comment'># ... code ...
2188
+ </span> <span class='kw'>end</span>
2189
+ <span class='kw'>end</span></code></pre>
2190
+
2191
+
2192
+ <p class="example_title"><div class='inline'>
2193
+ <p>Custom Scope</p>
2194
+ </div></p>
2195
+
2196
+ <pre class="example code"><code><span class='comment'># In this example, our base scope is a Hash
2197
+ </span><span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_posts'>posts</span><span class='op'>|</span>
2198
+ <span class='lbrace'>{</span> <span class='label'>post_ids:</span> <span class='id identifier rubyid_posts'>posts</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='symbol'>:id</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
2199
+ <span class='kw'>end</span></code></pre>
2200
+
2201
+
2202
+ <p class="example_title"><div class='inline'>
2203
+ <p>ActiveRecord via Adapter</p>
2204
+ </div></p>
2205
+
2206
+ <pre class="example code"><code><span class='kw'>class</span> <span class='const'>PostResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
2207
+ <span class='comment'># ... code ...
2208
+ </span> <span class='id identifier rubyid_has_many'>has_many</span> <span class='symbol'>:comments</span><span class='comma'>,</span>
2209
+ <span class='label'>scope:</span> <span class='tlambda'>-&gt;</span> <span class='tlambeg'>{</span> <span class='const'>Comment</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</span> <span class='rbrace'>}</span><span class='comma'>,</span>
2210
+ <span class='label'>resource:</span> <span class='const'>CommentResource</span><span class='comma'>,</span>
2211
+ <span class='label'>foreign_key:</span> <span class='symbol'>:post_id</span>
2212
+ <span class='kw'>end</span></code></pre>
2213
+
2214
+ </div>
2215
+
2216
+ <p class="tag_title">Yield Parameters:</p>
2217
+ <ul class="yieldparam">
2218
+
2219
+ <li>
2220
+
2221
+ <span class='name'>parents</span>
2222
+
2223
+
2224
+ <span class='type'></span>
2225
+
2226
+
2227
+
2228
+ &mdash;
2229
+ <div class='inline'><ul><li>
2230
+ <p>The resolved parent records</p>
2231
+ </li></ul>
2232
+ </div>
2233
+
2234
+ </li>
2235
+
2236
+ </ul>
2237
+
2238
+ <p class="tag_title">See Also:</p>
2239
+ <ul class="see">
2240
+
2241
+ <li><span class='object_link'><a href="Adapters/Abstract.html" title="JsonapiCompliable::Adapters::Abstract (class)">Adapters::Abstract</a></span></li>
2242
+
2243
+ <li><span class='object_link'><a href="Adapters/ActiveRecordSideloading.html#has_many-instance_method" title="JsonapiCompliable::Adapters::ActiveRecordSideloading#has_many (method)">Adapters::ActiveRecordSideloading#has_many</a></span></li>
2244
+
2245
+ <li><span class='object_link'><a href="#allow_sideload-instance_method" title="JsonapiCompliable::Sideload#allow_sideload (method)">#allow_sideload</a></span></li>
2246
+
2247
+ </ul>
2248
+
2249
+ </div><table class="source_code">
2250
+ <tr>
2251
+ <td>
2252
+ <pre class="lines">
2253
+
2254
+
2255
+ 129
2256
+ 130
2257
+ 131</pre>
2258
+ </td>
2259
+ <td>
2260
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 129</span>
2261
+
2262
+ <span class='kw'>def</span> <span class='id identifier rubyid_scope'>scope</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
2263
+ <span class='ivar'>@scope_proc</span> <span class='op'>=</span> <span class='id identifier rubyid_blk'>blk</span>
2264
+ <span class='kw'>end</span></pre>
2265
+ </td>
2266
+ </tr>
2267
+ </table>
2268
+ </div>
2269
+
2270
+ <div class="method_details ">
2271
+ <h3 class="signature " id="sideload-instance_method">
2272
+
2273
+ #<strong>sideload</strong>(name) &#x21d2; <tt>Object</tt>
2274
+
2275
+
2276
+
2277
+
2278
+
2279
+ </h3><div class="docstring">
2280
+ <div class="discussion">
2281
+
2282
+ <p>Fetch a Sideload object by its name</p>
2283
+
2284
+
2285
+ </div>
2286
+ </div>
2287
+ <div class="tags">
2288
+ <p class="tag_title">Parameters:</p>
2289
+ <ul class="param">
2290
+
2291
+ <li>
2292
+
2293
+ <span class='name'>name</span>
2294
+
2295
+
2296
+ <span class='type'>(<tt>Symbol</tt>)</span>
2297
+
2298
+
2299
+
2300
+ &mdash;
2301
+ <div class='inline'>
2302
+ <p>The name of the corresponding sideload</p>
2303
+ </div>
2304
+
2305
+ </li>
2306
+
2307
+ </ul>
2308
+
2309
+ <p class="tag_title">Returns:</p>
2310
+ <ul class="return">
2311
+
2312
+ <li>
2313
+
2314
+
2315
+ <span class='type'></span>
2316
+
2317
+
2318
+
2319
+
2320
+ <div class='inline'>
2321
+ <p>the corresponding Sideload object</p>
2322
+ </div>
2323
+
2324
+ </li>
2325
+
2326
+ </ul>
2327
+
2328
+ <p class="tag_title">See Also:</p>
2329
+ <ul class="see">
2330
+
2331
+ <li>+allow_sideload</li>
2332
+
2333
+ </ul>
2334
+
2335
+ </div><table class="source_code">
2336
+ <tr>
2337
+ <td>
2338
+ <pre class="lines">
2339
+
2340
+
2341
+ 279
2342
+ 280
2343
+ 281</pre>
2344
+ </td>
2345
+ <td>
2346
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 279</span>
2347
+
2348
+ <span class='kw'>def</span> <span class='id identifier rubyid_sideload'>sideload</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
2349
+ <span class='ivar'>@sideloads</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span>
2350
+ <span class='kw'>end</span></pre>
2351
+ </td>
2352
+ </tr>
2353
+ </table>
2354
+ </div>
2355
+
2356
+ <div class="method_details ">
2357
+ <h3 class="signature " id="to_hash-instance_method">
2358
+
2359
+ #<strong>to_hash</strong>(processed = []) &#x21d2; <tt>Hash</tt>
2360
+
2361
+
2362
+
2363
+
2364
+
2365
+ </h3><div class="docstring">
2366
+ <div class="discussion">
2367
+ <p class="note private">
2368
+ <strong>This method is part of a private API.</strong>
2369
+ You should avoid using this method if possible, as it may be removed or be changed in the future.
2370
+ </p>
2371
+
2372
+ <p>Looks at all nested sideload, and all nested sideloads for the
2373
+ corresponding Resources, and returns an Include Directive hash</p>
2374
+
2375
+ <p>For instance, this configuration:</p>
2376
+
2377
+ <pre class="code ruby"><code class="ruby"><span class='kw'>class</span> <span class='const'>BarResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
2378
+ <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:baz</span> <span class='kw'>do</span>
2379
+ <span class='kw'>end</span>
2380
+ <span class='kw'>end</span>
2381
+
2382
+ <span class='kw'>class</span> <span class='const'>PostResource</span> <span class='op'>&lt;</span> <span class='const'>ApplicationResource</span>
2383
+ <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:foo</span> <span class='kw'>do</span>
2384
+ <span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='symbol'>:bar</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='const'>BarResource</span> <span class='kw'>do</span>
2385
+ <span class='kw'>end</span>
2386
+ <span class='kw'>end</span>
2387
+ <span class='kw'>end</span>
2388
+ </code></pre>
2389
+
2390
+ <p><code>post_resource.sideloading.to_hash</code> would return</p>
2391
+
2392
+ <pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='label'>base:</span> <span class='lbrace'>{</span> <span class='label'>foo:</span> <span class='lbrace'>{</span> <span class='label'>bar:</span> <span class='lbrace'>{</span> <span class='label'>baz:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
2393
+ </code></pre>
2394
+
2395
+
2396
+ </div>
2397
+ </div>
2398
+ <div class="tags">
2399
+
2400
+ <p class="tag_title">Returns:</p>
2401
+ <ul class="return">
2402
+
2403
+ <li>
2404
+
2405
+
2406
+ <span class='type'>(<tt>Hash</tt>)</span>
2407
+
2408
+
2409
+
2410
+ &mdash;
2411
+ <div class='inline'>
2412
+ <p>The nested include hash</p>
2413
+ </div>
2414
+
2415
+ </li>
2416
+
2417
+ </ul>
2418
+
2419
+ </div><table class="source_code">
2420
+ <tr>
2421
+ <td>
2422
+ <pre class="lines">
2423
+
2424
+
2425
+ 306
2426
+ 307
2427
+ 308
2428
+ 309
2429
+ 310
2430
+ 311
2431
+ 312
2432
+ 313
2433
+ 314
2434
+ 315
2435
+ 316
2436
+ 317
2437
+ 318
2438
+ 319
2439
+ 320
2440
+ 321
2441
+ 322
2442
+ 323
2443
+ 324</pre>
2444
+ </td>
2445
+ <td>
2446
+ <pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/sideload.rb', line 306</span>
2447
+
2448
+ <span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_processed'>processed</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='rparen'>)</span>
2449
+ <span class='kw'>return</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_processed'>processed</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
2450
+ <span class='id identifier rubyid_processed'>processed</span> <span class='op'>&lt;&lt;</span> <span class='kw'>self</span>
2451
+
2452
+ <span class='id identifier rubyid_result'>result</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>=&gt;</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_tap'>tap</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_hash'>hash</span><span class='op'>|</span>
2453
+ <span class='ivar'>@sideloads</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_sideload'>sideload</span><span class='op'>|</span>
2454
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_sideload'>sideload</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_processed'>processed</span><span class='rparen'>)</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
2455
+
2456
+ <span class='kw'>if</span> <span class='id identifier rubyid_sideload'>sideload</span><span class='period'>.</span><span class='id identifier rubyid_polymorphic?'>polymorphic?</span>
2457
+ <span class='id identifier rubyid_sideload'>sideload</span><span class='period'>.</span><span class='id identifier rubyid_polymorphic_groups'>polymorphic_groups</span><span class='period'>.</span><span class='id identifier rubyid_each_pair'>each_pair</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_sl'>sl</span><span class='op'>|</span>
2458
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_nested_sideload_hash'>nested_sideload_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_sl'>sl</span><span class='comma'>,</span> <span class='id identifier rubyid_processed'>processed</span><span class='rparen'>)</span><span class='rparen'>)</span>
2459
+ <span class='kw'>end</span>
2460
+ <span class='kw'>else</span>
2461
+ <span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_nested_sideload_hash'>nested_sideload_hash</span><span class='lparen'>(</span><span class='id identifier rubyid_sideload'>sideload</span><span class='comma'>,</span> <span class='id identifier rubyid_processed'>processed</span><span class='rparen'>)</span><span class='rparen'>)</span>
2462
+ <span class='kw'>end</span>
2463
+ <span class='kw'>end</span>
2464
+ <span class='kw'>end</span>
2465
+ <span class='id identifier rubyid_result'>result</span>
2466
+ <span class='kw'>end</span></pre>
2467
+ </td>
2468
+ </tr>
2469
+ </table>
2470
+ </div>
2471
+
2472
+ </div>
2473
+
2474
+ </div>
2475
+
2476
+ <div id="footer">
2477
+ Generated on Fri May 5 15:53:22 2017 by
2478
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
2479
+ 0.9.9 (ruby-2.3.0).
2480
+ </div>
2481
+
2482
+ </div>
2483
+ </body>
2484
+ </html>