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.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +11 -3
- data/.yardopts +1 -0
- data/README.md +10 -1
- data/Rakefile +1 -0
- data/docs/JsonapiCompliable.html +202 -0
- data/docs/JsonapiCompliable/Adapters.html +119 -0
- data/docs/JsonapiCompliable/Adapters/Abstract.html +2285 -0
- data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +2151 -0
- data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +582 -0
- data/docs/JsonapiCompliable/Adapters/Null.html +1682 -0
- data/docs/JsonapiCompliable/Base.html +1395 -0
- data/docs/JsonapiCompliable/Deserializer.html +835 -0
- data/docs/JsonapiCompliable/Errors.html +115 -0
- data/docs/JsonapiCompliable/Errors/BadFilter.html +124 -0
- data/docs/JsonapiCompliable/Errors/StatNotFound.html +266 -0
- data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +264 -0
- data/docs/JsonapiCompliable/Errors/ValidationError.html +124 -0
- data/docs/JsonapiCompliable/Extensions.html +117 -0
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +212 -0
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +229 -0
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +242 -0
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +237 -0
- data/docs/JsonapiCompliable/Query.html +1099 -0
- data/docs/JsonapiCompliable/Rails.html +211 -0
- data/docs/JsonapiCompliable/Resource.html +5241 -0
- data/docs/JsonapiCompliable/Scope.html +703 -0
- data/docs/JsonapiCompliable/Scoping.html +117 -0
- data/docs/JsonapiCompliable/Scoping/Base.html +843 -0
- data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +318 -0
- data/docs/JsonapiCompliable/Scoping/ExtraFields.html +301 -0
- data/docs/JsonapiCompliable/Scoping/Filter.html +313 -0
- data/docs/JsonapiCompliable/Scoping/Filterable.html +364 -0
- data/docs/JsonapiCompliable/Scoping/Paginate.html +613 -0
- data/docs/JsonapiCompliable/Scoping/Sort.html +454 -0
- data/docs/JsonapiCompliable/SerializableTempId.html +216 -0
- data/docs/JsonapiCompliable/Sideload.html +2484 -0
- data/docs/JsonapiCompliable/Stats.html +117 -0
- data/docs/JsonapiCompliable/Stats/DSL.html +999 -0
- data/docs/JsonapiCompliable/Stats/Payload.html +391 -0
- data/docs/JsonapiCompliable/Util.html +117 -0
- data/docs/JsonapiCompliable/Util/FieldParams.html +228 -0
- data/docs/JsonapiCompliable/Util/Hash.html +471 -0
- data/docs/JsonapiCompliable/Util/IncludeParams.html +299 -0
- data/docs/JsonapiCompliable/Util/Persistence.html +435 -0
- data/docs/JsonapiCompliable/Util/RelationshipPayload.html +563 -0
- data/docs/JsonapiCompliable/Util/RenderOptions.html +250 -0
- data/docs/JsonapiCompliable/Util/ValidationResponse.html +532 -0
- data/docs/_index.html +527 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +492 -0
- data/docs/file.README.html +99 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +99 -0
- data/docs/js/app.js +248 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1731 -0
- data/docs/top-level-namespace.html +110 -0
- data/gemfiles/rails_5.gemfile +1 -1
- data/lib/jsonapi_compliable/adapters/abstract.rb +267 -4
- data/lib/jsonapi_compliable/adapters/active_record.rb +23 -1
- data/lib/jsonapi_compliable/adapters/null.rb +43 -3
- data/lib/jsonapi_compliable/base.rb +182 -33
- data/lib/jsonapi_compliable/deserializer.rb +90 -21
- data/lib/jsonapi_compliable/extensions/boolean_attribute.rb +12 -0
- data/lib/jsonapi_compliable/extensions/extra_attribute.rb +32 -0
- data/lib/jsonapi_compliable/extensions/temp_id.rb +11 -0
- data/lib/jsonapi_compliable/query.rb +94 -2
- data/lib/jsonapi_compliable/rails.rb +8 -0
- data/lib/jsonapi_compliable/resource.rb +548 -11
- data/lib/jsonapi_compliable/scope.rb +43 -1
- data/lib/jsonapi_compliable/scoping/base.rb +59 -8
- data/lib/jsonapi_compliable/scoping/default_filter.rb +33 -0
- data/lib/jsonapi_compliable/scoping/extra_fields.rb +33 -0
- data/lib/jsonapi_compliable/scoping/filter.rb +29 -2
- data/lib/jsonapi_compliable/scoping/filterable.rb +4 -0
- data/lib/jsonapi_compliable/scoping/paginate.rb +33 -0
- data/lib/jsonapi_compliable/scoping/sort.rb +18 -0
- data/lib/jsonapi_compliable/sideload.rb +229 -1
- data/lib/jsonapi_compliable/stats/dsl.rb +44 -0
- data/lib/jsonapi_compliable/stats/payload.rb +20 -0
- data/lib/jsonapi_compliable/util/field_params.rb +1 -0
- data/lib/jsonapi_compliable/util/hash.rb +18 -0
- data/lib/jsonapi_compliable/util/include_params.rb +22 -0
- data/lib/jsonapi_compliable/util/persistence.rb +13 -3
- data/lib/jsonapi_compliable/util/relationship_payload.rb +2 -0
- data/lib/jsonapi_compliable/util/render_options.rb +2 -0
- data/lib/jsonapi_compliable/util/validation_response.rb +16 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +60 -5
- data/gemfiles/rails_4.gemfile.lock +0 -208
- data/gemfiles/rails_5.gemfile.lock +0 -212
- data/lib/jsonapi_compliable/write.rb +0 -93
@@ -0,0 +1,582 @@
|
|
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::Adapters::ActiveRecordSideloading
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.9
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
pathId = "JsonapiCompliable::Adapters::ActiveRecordSideloading";
|
19
|
+
relpath = '../../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../../_index.html">Index (A)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span> » <span class='title'><span class='object_link'><a href="../Adapters.html" title="JsonapiCompliable::Adapters (module)">Adapters</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ActiveRecordSideloading</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::Adapters::ActiveRecordSideloading
|
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/adapters/active_record_sideloading.rb</dd>
|
82
|
+
</dl>
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
<h2>
|
95
|
+
Instance Method Summary
|
96
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
97
|
+
</h2>
|
98
|
+
|
99
|
+
<ul class="summary">
|
100
|
+
|
101
|
+
<li class="public ">
|
102
|
+
<span class="summary_signature">
|
103
|
+
|
104
|
+
<a href="#belongs_to-instance_method" title="#belongs_to (instance method)">#<strong>belongs_to</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, &blk) ⇒ Object </a>
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
</span>
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
119
|
+
|
120
|
+
</li>
|
121
|
+
|
122
|
+
|
123
|
+
<li class="public ">
|
124
|
+
<span class="summary_signature">
|
125
|
+
|
126
|
+
<a href="#has_and_belongs_to_many-instance_method" title="#has_and_belongs_to_many (instance method)">#<strong>has_and_belongs_to_many</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, as: nil, &blk) ⇒ Object </a>
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
</span>
|
131
|
+
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
141
|
+
|
142
|
+
</li>
|
143
|
+
|
144
|
+
|
145
|
+
<li class="public ">
|
146
|
+
<span class="summary_signature">
|
147
|
+
|
148
|
+
<a href="#has_many-instance_method" title="#has_many (instance method)">#<strong>has_many</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, &blk) ⇒ Object </a>
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
</span>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
163
|
+
|
164
|
+
</li>
|
165
|
+
|
166
|
+
|
167
|
+
<li class="public ">
|
168
|
+
<span class="summary_signature">
|
169
|
+
|
170
|
+
<a href="#has_one-instance_method" title="#has_one (instance method)">#<strong>has_one</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, &blk) ⇒ Object </a>
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
</span>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
185
|
+
|
186
|
+
</li>
|
187
|
+
|
188
|
+
|
189
|
+
<li class="public ">
|
190
|
+
<span class="summary_signature">
|
191
|
+
|
192
|
+
<a href="#polymorphic_belongs_to-instance_method" title="#polymorphic_belongs_to (instance method)">#<strong>polymorphic_belongs_to</strong>(association_name, group_by:, groups:, &blk) ⇒ Object </a>
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
</span>
|
197
|
+
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
207
|
+
|
208
|
+
</li>
|
209
|
+
|
210
|
+
|
211
|
+
</ul>
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
<div id="instance_method_details" class="method_details_list">
|
217
|
+
<h2>Instance Method Details</h2>
|
218
|
+
|
219
|
+
|
220
|
+
<div class="method_details first">
|
221
|
+
<h3 class="signature first" id="belongs_to-instance_method">
|
222
|
+
|
223
|
+
#<strong>belongs_to</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, &blk) ⇒ <tt>Object</tt>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
</h3><table class="source_code">
|
230
|
+
<tr>
|
231
|
+
<td>
|
232
|
+
<pre class="lines">
|
233
|
+
|
234
|
+
|
235
|
+
27
|
236
|
+
28
|
237
|
+
29
|
238
|
+
30
|
239
|
+
31
|
240
|
+
32
|
241
|
+
33
|
242
|
+
34
|
243
|
+
35
|
244
|
+
36
|
245
|
+
37
|
246
|
+
38
|
247
|
+
39
|
248
|
+
40
|
249
|
+
41
|
250
|
+
42
|
251
|
+
43
|
252
|
+
44
|
253
|
+
45</pre>
|
254
|
+
</td>
|
255
|
+
<td>
|
256
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record_sideloading.rb', line 27</span>
|
257
|
+
|
258
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_belongs_to'>belongs_to</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>resource:</span><span class='comma'>,</span> <span class='label'>foreign_key:</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
259
|
+
<span class='id identifier rubyid__scope'>_scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span>
|
260
|
+
|
261
|
+
<span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:belongs_to</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='label'>foreign_key:</span> <span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='id identifier rubyid_primary_key'>primary_key</span> <span class='kw'>do</span>
|
262
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='op'>|</span>
|
263
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span> <span class='op'>=</span> <span class='id identifier rubyid_parents'>parents</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
264
|
+
<span class='id identifier rubyid__scope'>_scope</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span> <span class='op'>=></span> <span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='rparen'>)</span>
|
265
|
+
<span class='kw'>end</span>
|
266
|
+
|
267
|
+
<span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='op'>|</span>
|
268
|
+
<span class='id identifier rubyid_parents'>parents</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_parent'>parent</span><span class='op'>|</span>
|
269
|
+
<span class='id identifier rubyid_relevant_child'>relevant_child</span> <span class='op'>=</span> <span class='id identifier rubyid_children'>children</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_c'>c</span><span class='op'>|</span> <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='id identifier rubyid_foreign_key'>foreign_key</span><span class='rparen'>)</span> <span class='op'>==</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
270
|
+
<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_association_name'>association_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_relevant_child'>relevant_child</span><span class='rparen'>)</span>
|
271
|
+
<span class='kw'>end</span>
|
272
|
+
<span class='kw'>end</span>
|
273
|
+
<span class='kw'>end</span>
|
274
|
+
|
275
|
+
<span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&</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>
|
276
|
+
<span class='kw'>end</span></pre>
|
277
|
+
</td>
|
278
|
+
</tr>
|
279
|
+
</table>
|
280
|
+
</div>
|
281
|
+
|
282
|
+
<div class="method_details ">
|
283
|
+
<h3 class="signature " id="has_and_belongs_to_many-instance_method">
|
284
|
+
|
285
|
+
#<strong>has_and_belongs_to_many</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, as: nil, &blk) ⇒ <tt>Object</tt>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
</h3><table class="source_code">
|
292
|
+
<tr>
|
293
|
+
<td>
|
294
|
+
<pre class="lines">
|
295
|
+
|
296
|
+
|
297
|
+
69
|
298
|
+
70
|
299
|
+
71
|
300
|
+
72
|
301
|
+
73
|
302
|
+
74
|
303
|
+
75
|
304
|
+
76
|
305
|
+
77
|
306
|
+
78
|
307
|
+
79
|
308
|
+
80
|
309
|
+
81
|
310
|
+
82
|
311
|
+
83
|
312
|
+
84
|
313
|
+
85
|
314
|
+
86
|
315
|
+
87
|
316
|
+
88
|
317
|
+
89
|
318
|
+
90
|
319
|
+
91
|
320
|
+
92
|
321
|
+
93
|
322
|
+
94</pre>
|
323
|
+
</td>
|
324
|
+
<td>
|
325
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record_sideloading.rb', line 69</span>
|
326
|
+
|
327
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_and_belongs_to_many'>has_and_belongs_to_many</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>resource:</span><span class='comma'>,</span> <span class='label'>foreign_key:</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='label'>as:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
328
|
+
<span class='id identifier rubyid_through'>through</span> <span class='op'>=</span> <span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
329
|
+
<span class='id identifier rubyid_fk'>fk</span> <span class='op'>=</span> <span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
330
|
+
<span class='id identifier rubyid__scope'>_scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span>
|
331
|
+
|
332
|
+
<span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='id identifier rubyid_resource'>resource</span> <span class='kw'>do</span>
|
333
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='op'>|</span>
|
334
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span> <span class='op'>=</span> <span class='id identifier rubyid_parents'>parents</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
335
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_uniq!'>uniq!</span>
|
336
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_compact!'>compact!</span>
|
337
|
+
<span class='id identifier rubyid__scope'>_scope</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_joins'>joins</span><span class='lparen'>(</span><span class='id identifier rubyid_through'>through</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_through'>through</span> <span class='op'>=></span> <span class='lbrace'>{</span> <span class='id identifier rubyid_fk'>fk</span> <span class='op'>=></span> <span class='id identifier rubyid_parent_ids'>parent_ids</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
338
|
+
<span class='kw'>end</span>
|
339
|
+
|
340
|
+
<span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='op'>|</span>
|
341
|
+
<span class='id identifier rubyid_parents'>parents</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_parent'>parent</span><span class='op'>|</span>
|
342
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_loaded!'>loaded!</span>
|
343
|
+
<span class='id identifier rubyid_relevant_children'>relevant_children</span> <span class='op'>=</span> <span class='id identifier rubyid_children'>children</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_through'>through</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_ct'>ct</span><span class='op'>|</span> <span class='id identifier rubyid_ct'>ct</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_fk'>fk</span><span class='rparen'>)</span> <span class='op'>==</span> <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='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
344
|
+
<span class='id identifier rubyid_relevant_children'>relevant_children</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_c'>c</span><span class='op'>|</span>
|
345
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_add_to_target'>add_to_target</span><span class='lparen'>(</span><span class='id identifier rubyid_c'>c</span><span class='comma'>,</span> <span class='symbol'>:skip_callbacks</span><span class='rparen'>)</span>
|
346
|
+
<span class='kw'>end</span>
|
347
|
+
<span class='kw'>end</span>
|
348
|
+
<span class='kw'>end</span>
|
349
|
+
|
350
|
+
<span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&</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>
|
351
|
+
<span class='kw'>end</span>
|
352
|
+
<span class='kw'>end</span></pre>
|
353
|
+
</td>
|
354
|
+
</tr>
|
355
|
+
</table>
|
356
|
+
</div>
|
357
|
+
|
358
|
+
<div class="method_details ">
|
359
|
+
<h3 class="signature " id="has_many-instance_method">
|
360
|
+
|
361
|
+
#<strong>has_many</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, &blk) ⇒ <tt>Object</tt>
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
</h3><table class="source_code">
|
368
|
+
<tr>
|
369
|
+
<td>
|
370
|
+
<pre class="lines">
|
371
|
+
|
372
|
+
|
373
|
+
4
|
374
|
+
5
|
375
|
+
6
|
376
|
+
7
|
377
|
+
8
|
378
|
+
9
|
379
|
+
10
|
380
|
+
11
|
381
|
+
12
|
382
|
+
13
|
383
|
+
14
|
384
|
+
15
|
385
|
+
16
|
386
|
+
17
|
387
|
+
18
|
388
|
+
19
|
389
|
+
20
|
390
|
+
21
|
391
|
+
22
|
392
|
+
23
|
393
|
+
24
|
394
|
+
25</pre>
|
395
|
+
</td>
|
396
|
+
<td>
|
397
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record_sideloading.rb', line 4</span>
|
398
|
+
|
399
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_many'>has_many</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>resource:</span><span class='comma'>,</span> <span class='label'>foreign_key:</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
400
|
+
<span class='id identifier rubyid__scope'>_scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span>
|
401
|
+
|
402
|
+
<span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>type:</span> <span class='symbol'>:has_many</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='label'>foreign_key:</span> <span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='id identifier rubyid_primary_key'>primary_key</span> <span class='kw'>do</span>
|
403
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='op'>|</span>
|
404
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span> <span class='op'>=</span> <span class='id identifier rubyid_parents'>parents</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
405
|
+
<span class='id identifier rubyid__scope'>_scope</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_foreign_key'>foreign_key</span> <span class='op'>=></span> <span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='rparen'>)</span>
|
406
|
+
<span class='kw'>end</span>
|
407
|
+
|
408
|
+
<span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='op'>|</span>
|
409
|
+
<span class='id identifier rubyid_parents'>parents</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_parent'>parent</span><span class='op'>|</span>
|
410
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_loaded!'>loaded!</span>
|
411
|
+
<span class='id identifier rubyid_relevant_children'>relevant_children</span> <span class='op'>=</span> <span class='id identifier rubyid_children'>children</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='rparen'>)</span> <span class='op'>==</span> <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='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
412
|
+
<span class='id identifier rubyid_relevant_children'>relevant_children</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_c'>c</span><span class='op'>|</span>
|
413
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_add_to_target'>add_to_target</span><span class='lparen'>(</span><span class='id identifier rubyid_c'>c</span><span class='comma'>,</span> <span class='symbol'>:skip_callbacks</span><span class='rparen'>)</span>
|
414
|
+
<span class='kw'>end</span>
|
415
|
+
<span class='kw'>end</span>
|
416
|
+
<span class='kw'>end</span>
|
417
|
+
|
418
|
+
<span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&</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>
|
419
|
+
<span class='kw'>end</span>
|
420
|
+
<span class='kw'>end</span></pre>
|
421
|
+
</td>
|
422
|
+
</tr>
|
423
|
+
</table>
|
424
|
+
</div>
|
425
|
+
|
426
|
+
<div class="method_details ">
|
427
|
+
<h3 class="signature " id="has_one-instance_method">
|
428
|
+
|
429
|
+
#<strong>has_one</strong>(association_name, scope: nil, resource:, foreign_key:, primary_key: :id, &blk) ⇒ <tt>Object</tt>
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
</h3><table class="source_code">
|
436
|
+
<tr>
|
437
|
+
<td>
|
438
|
+
<pre class="lines">
|
439
|
+
|
440
|
+
|
441
|
+
47
|
442
|
+
48
|
443
|
+
49
|
444
|
+
50
|
445
|
+
51
|
446
|
+
52
|
447
|
+
53
|
448
|
+
54
|
449
|
+
55
|
450
|
+
56
|
451
|
+
57
|
452
|
+
58
|
453
|
+
59
|
454
|
+
60
|
455
|
+
61
|
456
|
+
62
|
457
|
+
63
|
458
|
+
64
|
459
|
+
65
|
460
|
+
66
|
461
|
+
67</pre>
|
462
|
+
</td>
|
463
|
+
<td>
|
464
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record_sideloading.rb', line 47</span>
|
465
|
+
|
466
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_has_one'>has_one</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>scope:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>resource:</span><span class='comma'>,</span> <span class='label'>foreign_key:</span><span class='comma'>,</span> <span class='label'>primary_key:</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
467
|
+
<span class='id identifier rubyid__scope'>_scope</span> <span class='op'>=</span> <span class='id identifier rubyid_scope'>scope</span>
|
468
|
+
|
469
|
+
<span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='id identifier rubyid_resource'>resource</span> <span class='kw'>do</span>
|
470
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='op'>|</span>
|
471
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span> <span class='op'>=</span> <span class='id identifier rubyid_parents'>parents</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
472
|
+
<span class='id identifier rubyid__scope'>_scope</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_foreign_key'>foreign_key</span> <span class='op'>=></span> <span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_uniq'>uniq</span><span class='period'>.</span><span class='id identifier rubyid_compact'>compact</span><span class='rparen'>)</span>
|
473
|
+
<span class='kw'>end</span>
|
474
|
+
|
475
|
+
<span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='op'>|</span>
|
476
|
+
<span class='id identifier rubyid_parents'>parents</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_parent'>parent</span><span class='op'>|</span>
|
477
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_loaded!'>loaded!</span>
|
478
|
+
<span class='id identifier rubyid_relevant_child'>relevant_child</span> <span class='op'>=</span> <span class='id identifier rubyid_children'>children</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_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='rparen'>)</span> <span class='op'>==</span> <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='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
479
|
+
<span class='kw'>next</span> <span class='kw'>unless</span> <span class='id identifier rubyid_relevant_child'>relevant_child</span>
|
480
|
+
<span class='id identifier rubyid_parent'>parent</span><span class='period'>.</span><span class='id identifier rubyid_association'>association</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_replace'>replace</span><span class='lparen'>(</span><span class='id identifier rubyid_relevant_child'>relevant_child</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
481
|
+
<span class='kw'>end</span>
|
482
|
+
<span class='kw'>end</span>
|
483
|
+
|
484
|
+
<span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&</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>
|
485
|
+
<span class='kw'>end</span>
|
486
|
+
<span class='kw'>end</span></pre>
|
487
|
+
</td>
|
488
|
+
</tr>
|
489
|
+
</table>
|
490
|
+
</div>
|
491
|
+
|
492
|
+
<div class="method_details ">
|
493
|
+
<h3 class="signature " id="polymorphic_belongs_to-instance_method">
|
494
|
+
|
495
|
+
#<strong>polymorphic_belongs_to</strong>(association_name, group_by:, groups:, &blk) ⇒ <tt>Object</tt>
|
496
|
+
|
497
|
+
|
498
|
+
|
499
|
+
|
500
|
+
|
501
|
+
</h3><table class="source_code">
|
502
|
+
<tr>
|
503
|
+
<td>
|
504
|
+
<pre class="lines">
|
505
|
+
|
506
|
+
|
507
|
+
96
|
508
|
+
97
|
509
|
+
98
|
510
|
+
99
|
511
|
+
100
|
512
|
+
101
|
513
|
+
102
|
514
|
+
103
|
515
|
+
104
|
516
|
+
105
|
517
|
+
106
|
518
|
+
107
|
519
|
+
108
|
520
|
+
109
|
521
|
+
110
|
522
|
+
111
|
523
|
+
112
|
524
|
+
113
|
525
|
+
114
|
526
|
+
115
|
527
|
+
116
|
528
|
+
117
|
529
|
+
118
|
530
|
+
119
|
531
|
+
120
|
532
|
+
121
|
533
|
+
122</pre>
|
534
|
+
</td>
|
535
|
+
<td>
|
536
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/adapters/active_record_sideloading.rb', line 96</span>
|
537
|
+
|
538
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_polymorphic_belongs_to'>polymorphic_belongs_to</span><span class='lparen'>(</span><span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>group_by:</span><span class='comma'>,</span> <span class='label'>groups:</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
539
|
+
<span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_association_name'>association_name</span><span class='comma'>,</span> <span class='label'>polymorphic:</span> <span class='kw'>true</span> <span class='kw'>do</span>
|
540
|
+
<span class='id identifier rubyid_group_by'>group_by</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_group_by'>group_by</span><span class='rparen'>)</span>
|
541
|
+
|
542
|
+
<span class='id identifier rubyid_groups'>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_config'>config</span><span class='op'>|</span>
|
543
|
+
<span class='id identifier rubyid_primary_key'>primary_key</span> <span class='op'>=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:primary_key</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='symbol'>:id</span>
|
544
|
+
<span class='id identifier rubyid_foreign_key'>foreign_key</span> <span class='op'>=</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:foreign_key</span><span class='rbracket'>]</span>
|
545
|
+
|
546
|
+
<span class='id identifier rubyid_allow_sideload'>allow_sideload</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:resource</span><span class='rbracket'>]</span> <span class='kw'>do</span>
|
547
|
+
<span class='id identifier rubyid_scope'>scope</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='op'>|</span>
|
548
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span> <span class='op'>=</span> <span class='id identifier rubyid_parents'>parents</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</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_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_foreign_key'>foreign_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
549
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_compact!'>compact!</span>
|
550
|
+
<span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='period'>.</span><span class='id identifier rubyid_uniq!'>uniq!</span>
|
551
|
+
<span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:scope</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span><span class='period'>.</span><span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span> <span class='op'>=></span> <span class='id identifier rubyid_parent_ids'>parent_ids</span><span class='rparen'>)</span>
|
552
|
+
<span class='kw'>end</span>
|
553
|
+
|
554
|
+
<span class='id identifier rubyid_assign'>assign</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_parents'>parents</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='op'>|</span>
|
555
|
+
<span class='id identifier rubyid_parents'>parents</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_parent'>parent</span><span class='op'>|</span>
|
556
|
+
<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_association_name'>association_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</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_c'>c</span><span class='op'>|</span> <span class='id identifier rubyid_c'>c</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_primary_key'>primary_key</span><span class='rparen'>)</span> <span class='op'>==</span> <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='id identifier rubyid_foreign_key'>foreign_key</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
557
|
+
<span class='kw'>end</span>
|
558
|
+
<span class='kw'>end</span>
|
559
|
+
<span class='kw'>end</span>
|
560
|
+
<span class='kw'>end</span>
|
561
|
+
<span class='kw'>end</span>
|
562
|
+
|
563
|
+
<span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&</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>
|
564
|
+
<span class='kw'>end</span></pre>
|
565
|
+
</td>
|
566
|
+
</tr>
|
567
|
+
</table>
|
568
|
+
</div>
|
569
|
+
|
570
|
+
</div>
|
571
|
+
|
572
|
+
</div>
|
573
|
+
|
574
|
+
<div id="footer">
|
575
|
+
Generated on Fri May 5 15:53:22 2017 by
|
576
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
577
|
+
0.9.9 (ruby-2.3.0).
|
578
|
+
</div>
|
579
|
+
|
580
|
+
</div>
|
581
|
+
</body>
|
582
|
+
</html>
|