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,299 @@
|
|
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::Util::IncludeParams
|
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::Util::IncludeParams";
|
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 (I)</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="../Util.html" title="JsonapiCompliable::Util (module)">Util</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">IncludeParams</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::Util::IncludeParams
|
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::Util::IncludeParams</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/util/include_params.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>Utility class for dealing with Include Directives</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<h2>
|
122
|
+
Class Method Summary
|
123
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
124
|
+
</h2>
|
125
|
+
|
126
|
+
<ul class="summary">
|
127
|
+
|
128
|
+
<li class="public ">
|
129
|
+
<span class="summary_signature">
|
130
|
+
|
131
|
+
<a href="#scrub-class_method" title="scrub (class method)">.<strong>scrub</strong>(requested_includes, allowed_includes) ⇒ Hash </a>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
</span>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
<span class="summary_desc"><div class='inline'>
|
146
|
+
<p>Let's say the user requested these sideloads:.</p>
|
147
|
+
</div></span>
|
148
|
+
|
149
|
+
</li>
|
150
|
+
|
151
|
+
|
152
|
+
</ul>
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<div id="class_method_details" class="method_details_list">
|
158
|
+
<h2>Class Method Details</h2>
|
159
|
+
|
160
|
+
|
161
|
+
<div class="method_details first">
|
162
|
+
<h3 class="signature first" id="scrub-class_method">
|
163
|
+
|
164
|
+
.<strong>scrub</strong>(requested_includes, allowed_includes) ⇒ <tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
</h3><div class="docstring">
|
171
|
+
<div class="discussion">
|
172
|
+
|
173
|
+
<p>Let's say the user requested these sideloads:</p>
|
174
|
+
|
175
|
+
<pre class="code ruby"><code class="ruby">GET /posts?include=comments.author</code></pre>
|
176
|
+
|
177
|
+
<p>But our resource had this code:</p>
|
178
|
+
|
179
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_sideload_whitelist'>sideload_whitelist</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='label'>index:</span> <span class='lbracket'>[</span><span class='symbol'>:comments</span><span class='rbracket'>]</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
180
|
+
</code></pre>
|
181
|
+
|
182
|
+
<p>We should drop the 'author' sideload from the request.</p>
|
183
|
+
|
184
|
+
<p>Hashes become 'include directive hashes' within the library. ie</p>
|
185
|
+
|
186
|
+
<pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span><span class='symbol'>:tags</span><span class='comma'>,</span> <span class='lbrace'>{</span> <span class='label'>comments:</span> <span class='symbol'>:author</span> <span class='rbrace'>}</span><span class='rbracket'>]</span>
|
187
|
+
</code></pre>
|
188
|
+
|
189
|
+
<p>Becomes</p>
|
190
|
+
|
191
|
+
<pre class="code ruby"><code class="ruby"><span class='lbrace'>{</span> <span class='label'>tags:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>comments:</span> <span class='lbrace'>{</span> <span class='label'>author:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
192
|
+
</code></pre>
|
193
|
+
|
194
|
+
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
<div class="tags">
|
198
|
+
<p class="tag_title">Parameters:</p>
|
199
|
+
<ul class="param">
|
200
|
+
|
201
|
+
<li>
|
202
|
+
|
203
|
+
<span class='name'>requested_includes</span>
|
204
|
+
|
205
|
+
|
206
|
+
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>)</span>
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
—
|
211
|
+
<div class='inline'>
|
212
|
+
<p>the nested hash the user requested</p>
|
213
|
+
</div>
|
214
|
+
|
215
|
+
</li>
|
216
|
+
|
217
|
+
<li>
|
218
|
+
|
219
|
+
<span class='name'>allowed_includes</span>
|
220
|
+
|
221
|
+
|
222
|
+
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>)</span>
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
—
|
227
|
+
<div class='inline'>
|
228
|
+
<p>the nested hash configured via DSL</p>
|
229
|
+
</div>
|
230
|
+
|
231
|
+
</li>
|
232
|
+
|
233
|
+
</ul>
|
234
|
+
|
235
|
+
<p class="tag_title">Returns:</p>
|
236
|
+
<ul class="return">
|
237
|
+
|
238
|
+
<li>
|
239
|
+
|
240
|
+
|
241
|
+
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>)</span>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
—
|
246
|
+
<div class='inline'>
|
247
|
+
<p>the scrubbed hash</p>
|
248
|
+
</div>
|
249
|
+
|
250
|
+
</li>
|
251
|
+
|
252
|
+
</ul>
|
253
|
+
|
254
|
+
</div><table class="source_code">
|
255
|
+
<tr>
|
256
|
+
<td>
|
257
|
+
<pre class="lines">
|
258
|
+
|
259
|
+
|
260
|
+
27
|
261
|
+
28
|
262
|
+
29
|
263
|
+
30
|
264
|
+
31
|
265
|
+
32
|
266
|
+
33
|
267
|
+
34
|
268
|
+
35</pre>
|
269
|
+
</td>
|
270
|
+
<td>
|
271
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/util/include_params.rb', line 27</span>
|
272
|
+
|
273
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_scrub'>scrub</span><span class='lparen'>(</span><span class='id identifier rubyid_requested_includes'>requested_includes</span><span class='comma'>,</span> <span class='id identifier rubyid_allowed_includes'>allowed_includes</span><span class='rparen'>)</span>
|
274
|
+
<span class='lbrace'>{</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_valid'>valid</span><span class='op'>|</span>
|
275
|
+
<span class='id identifier rubyid_requested_includes'>requested_includes</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_sub_hash'>sub_hash</span><span class='op'>|</span>
|
276
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_allowed_includes'>allowed_includes</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span>
|
277
|
+
<span class='id identifier rubyid_valid'>valid</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_scrub'>scrub</span><span class='lparen'>(</span><span class='id identifier rubyid_sub_hash'>sub_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_allowed_includes'>allowed_includes</span><span class='lbracket'>[</span><span class='id identifier rubyid_key'>key</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
278
|
+
<span class='kw'>end</span>
|
279
|
+
<span class='kw'>end</span>
|
280
|
+
<span class='kw'>end</span>
|
281
|
+
<span class='kw'>end</span></pre>
|
282
|
+
</td>
|
283
|
+
</tr>
|
284
|
+
</table>
|
285
|
+
</div>
|
286
|
+
|
287
|
+
</div>
|
288
|
+
|
289
|
+
</div>
|
290
|
+
|
291
|
+
<div id="footer">
|
292
|
+
Generated on Fri May 5 15:53:23 2017 by
|
293
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
294
|
+
0.9.9 (ruby-2.3.0).
|
295
|
+
</div>
|
296
|
+
|
297
|
+
</div>
|
298
|
+
</body>
|
299
|
+
</html>
|
@@ -0,0 +1,435 @@
|
|
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::Util::Persistence
|
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::Util::Persistence";
|
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 (P)</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="../Util.html" title="JsonapiCompliable::Util (module)">Util</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Persistence</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::Util::Persistence
|
63
|
+
|
64
|
+
|
65
|
+
<span class="private note title">Private</span>
|
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::Util::Persistence</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/util/persistence.rb</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
</div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
<p class="note private">
|
105
|
+
<strong>This class is part of a private API.</strong>
|
106
|
+
You should avoid using this class if possible, as it may be removed or be changed in the future.
|
107
|
+
</p>
|
108
|
+
|
109
|
+
<p>Save the given Resource#model, and all of its nested relationships.</p>
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
</div>
|
114
|
+
<div class="tags">
|
115
|
+
|
116
|
+
|
117
|
+
</div>
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<h2>
|
126
|
+
Instance Method Summary
|
127
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
128
|
+
</h2>
|
129
|
+
|
130
|
+
<ul class="summary">
|
131
|
+
|
132
|
+
<li class="public ">
|
133
|
+
<span class="summary_signature">
|
134
|
+
|
135
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(resource, meta, attributes, relationships) ⇒ Persistence </a>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
</span>
|
140
|
+
|
141
|
+
|
142
|
+
<span class="note title constructor">constructor</span>
|
143
|
+
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<span class="private note title">private</span>
|
149
|
+
|
150
|
+
|
151
|
+
<span class="summary_desc"><div class='inline'>
|
152
|
+
<p>A new instance of Persistence.</p>
|
153
|
+
</div></span>
|
154
|
+
|
155
|
+
</li>
|
156
|
+
|
157
|
+
|
158
|
+
<li class="public ">
|
159
|
+
<span class="summary_signature">
|
160
|
+
|
161
|
+
<a href="#run-instance_method" title="#run (instance method)">#<strong>run</strong> ⇒ Object </a>
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
</span>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
<span class="private note title">private</span>
|
173
|
+
|
174
|
+
|
175
|
+
<span class="summary_desc"><div class='inline'>
|
176
|
+
<p>Perform the actual save logic.</p>
|
177
|
+
</div></span>
|
178
|
+
|
179
|
+
</li>
|
180
|
+
|
181
|
+
|
182
|
+
</ul>
|
183
|
+
|
184
|
+
|
185
|
+
<div id="constructor_details" class="method_details_list">
|
186
|
+
<h2>Constructor Details</h2>
|
187
|
+
|
188
|
+
<div class="method_details first">
|
189
|
+
<h3 class="signature first" id="initialize-instance_method">
|
190
|
+
|
191
|
+
#<strong>initialize</strong>(resource, meta, attributes, relationships) ⇒ <tt><span class='object_link'><a href="" title="JsonapiCompliable::Util::Persistence (class)">Persistence</a></span></tt>
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
</h3><div class="docstring">
|
198
|
+
<div class="discussion">
|
199
|
+
<p class="note private">
|
200
|
+
<strong>This method is part of a private API.</strong>
|
201
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
202
|
+
</p>
|
203
|
+
|
204
|
+
<p>Returns a new instance of Persistence</p>
|
205
|
+
|
206
|
+
|
207
|
+
</div>
|
208
|
+
</div>
|
209
|
+
<div class="tags">
|
210
|
+
<p class="tag_title">Parameters:</p>
|
211
|
+
<ul class="param">
|
212
|
+
|
213
|
+
<li>
|
214
|
+
|
215
|
+
<span class='name'>resource</span>
|
216
|
+
|
217
|
+
|
218
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></tt>)</span>
|
219
|
+
|
220
|
+
|
221
|
+
|
222
|
+
—
|
223
|
+
<div class='inline'>
|
224
|
+
<p>the resource instance</p>
|
225
|
+
</div>
|
226
|
+
|
227
|
+
</li>
|
228
|
+
|
229
|
+
<li>
|
230
|
+
|
231
|
+
<span class='name'>meta</span>
|
232
|
+
|
233
|
+
|
234
|
+
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>)</span>
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
—
|
239
|
+
<div class='inline'>
|
240
|
+
<p>see (Deserializer#meta)</p>
|
241
|
+
</div>
|
242
|
+
|
243
|
+
</li>
|
244
|
+
|
245
|
+
<li>
|
246
|
+
|
247
|
+
<span class='name'>attributes</span>
|
248
|
+
|
249
|
+
|
250
|
+
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>)</span>
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
—
|
255
|
+
<div class='inline'>
|
256
|
+
<p>see (Deserializer#attributes)</p>
|
257
|
+
</div>
|
258
|
+
|
259
|
+
</li>
|
260
|
+
|
261
|
+
<li>
|
262
|
+
|
263
|
+
<span class='name'>relationships</span>
|
264
|
+
|
265
|
+
|
266
|
+
<span class='type'>(<tt><span class='object_link'><a href="Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></tt>)</span>
|
267
|
+
|
268
|
+
|
269
|
+
|
270
|
+
—
|
271
|
+
<div class='inline'>
|
272
|
+
<p>see (Deserializer#relationships)</p>
|
273
|
+
</div>
|
274
|
+
|
275
|
+
</li>
|
276
|
+
|
277
|
+
</ul>
|
278
|
+
|
279
|
+
|
280
|
+
</div><table class="source_code">
|
281
|
+
<tr>
|
282
|
+
<td>
|
283
|
+
<pre class="lines">
|
284
|
+
|
285
|
+
|
286
|
+
8
|
287
|
+
9
|
288
|
+
10
|
289
|
+
11
|
290
|
+
12
|
291
|
+
13</pre>
|
292
|
+
</td>
|
293
|
+
<td>
|
294
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/util/persistence.rb', line 8</span>
|
295
|
+
|
296
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_resource'>resource</span><span class='comma'>,</span> <span class='id identifier rubyid_meta'>meta</span><span class='comma'>,</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='comma'>,</span> <span class='id identifier rubyid_relationships'>relationships</span><span class='rparen'>)</span>
|
297
|
+
<span class='ivar'>@resource</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span>
|
298
|
+
<span class='ivar'>@meta</span> <span class='op'>=</span> <span class='id identifier rubyid_meta'>meta</span>
|
299
|
+
<span class='ivar'>@attributes</span> <span class='op'>=</span> <span class='id identifier rubyid_attributes'>attributes</span>
|
300
|
+
<span class='ivar'>@relationships</span> <span class='op'>=</span> <span class='id identifier rubyid_relationships'>relationships</span>
|
301
|
+
<span class='kw'>end</span></pre>
|
302
|
+
</td>
|
303
|
+
</tr>
|
304
|
+
</table>
|
305
|
+
</div>
|
306
|
+
|
307
|
+
</div>
|
308
|
+
|
309
|
+
|
310
|
+
<div id="instance_method_details" class="method_details_list">
|
311
|
+
<h2>Instance Method Details</h2>
|
312
|
+
|
313
|
+
|
314
|
+
<div class="method_details first">
|
315
|
+
<h3 class="signature first" id="run-instance_method">
|
316
|
+
|
317
|
+
#<strong>run</strong> ⇒ <tt>Object</tt>
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
</h3><div class="docstring">
|
324
|
+
<div class="discussion">
|
325
|
+
<p class="note private">
|
326
|
+
<strong>This method is part of a private API.</strong>
|
327
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
328
|
+
</p>
|
329
|
+
|
330
|
+
<p>Perform the actual save logic.</p>
|
331
|
+
|
332
|
+
<p>belongs_to must be processed before/separately from has_many - we need to
|
333
|
+
know the primary key value of the parent before persisting the child.</p>
|
334
|
+
|
335
|
+
<p>Flow:</p>
|
336
|
+
<ul><li>
|
337
|
+
<p>process parents</p>
|
338
|
+
</li><li>
|
339
|
+
<p>update attributes to reflect parent primary keys</p>
|
340
|
+
</li><li>
|
341
|
+
<p>persist current object</p>
|
342
|
+
</li><li>
|
343
|
+
<p>associate temp id with current object</p>
|
344
|
+
</li><li>
|
345
|
+
<p>associate parent objects with current object</p>
|
346
|
+
</li><li>
|
347
|
+
<p>process children</p>
|
348
|
+
</li><li>
|
349
|
+
<p>associate children</p>
|
350
|
+
</li><li>
|
351
|
+
<p>return current object</p>
|
352
|
+
</li></ul>
|
353
|
+
|
354
|
+
|
355
|
+
</div>
|
356
|
+
</div>
|
357
|
+
<div class="tags">
|
358
|
+
|
359
|
+
<p class="tag_title">Returns:</p>
|
360
|
+
<ul class="return">
|
361
|
+
|
362
|
+
<li>
|
363
|
+
|
364
|
+
|
365
|
+
<span class='type'></span>
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
<div class='inline'>
|
371
|
+
<p>the persisted model instance</p>
|
372
|
+
</div>
|
373
|
+
|
374
|
+
</li>
|
375
|
+
|
376
|
+
</ul>
|
377
|
+
|
378
|
+
</div><table class="source_code">
|
379
|
+
<tr>
|
380
|
+
<td>
|
381
|
+
<pre class="lines">
|
382
|
+
|
383
|
+
|
384
|
+
32
|
385
|
+
33
|
386
|
+
34
|
387
|
+
35
|
388
|
+
36
|
389
|
+
37
|
390
|
+
38
|
391
|
+
39
|
392
|
+
40
|
393
|
+
41
|
394
|
+
42
|
395
|
+
43
|
396
|
+
44
|
397
|
+
45
|
398
|
+
46</pre>
|
399
|
+
</td>
|
400
|
+
<td>
|
401
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/util/persistence.rb', line 32</span>
|
402
|
+
|
403
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
|
404
|
+
<span class='id identifier rubyid_parents'>parents</span> <span class='op'>=</span> <span class='id identifier rubyid_process_belongs_to'>process_belongs_to</span><span class='lparen'>(</span><span class='ivar'>@relationships</span><span class='rparen'>)</span>
|
405
|
+
<span class='id identifier rubyid_update_foreign_key_for_parents'>update_foreign_key_for_parents</span><span class='lparen'>(</span><span class='id identifier rubyid_parents'>parents</span><span class='rparen'>)</span>
|
406
|
+
|
407
|
+
<span class='id identifier rubyid_persisted'>persisted</span> <span class='op'>=</span> <span class='id identifier rubyid_persist_object'>persist_object</span><span class='lparen'>(</span><span class='ivar'>@meta</span><span class='lbracket'>[</span><span class='symbol'>:method</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='ivar'>@attributes</span><span class='rparen'>)</span>
|
408
|
+
<span class='id identifier rubyid_assign_temp_id'>assign_temp_id</span><span class='lparen'>(</span><span class='id identifier rubyid_persisted'>persisted</span><span class='comma'>,</span> <span class='ivar'>@meta</span><span class='lbracket'>[</span><span class='symbol'>:temp_id</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
409
|
+
<span class='id identifier rubyid_associate_parents'>associate_parents</span><span class='lparen'>(</span><span class='id identifier rubyid_persisted'>persisted</span><span class='comma'>,</span> <span class='id identifier rubyid_parents'>parents</span><span class='rparen'>)</span>
|
410
|
+
|
411
|
+
<span class='id identifier rubyid_children'>children</span> <span class='op'>=</span> <span class='id identifier rubyid_process_has_many'>process_has_many</span><span class='lparen'>(</span><span class='ivar'>@relationships</span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_x'>x</span><span class='op'>|</span>
|
412
|
+
<span class='id identifier rubyid_update_foreign_key'>update_foreign_key</span><span class='lparen'>(</span><span class='id identifier rubyid_persisted'>persisted</span><span class='comma'>,</span> <span class='id identifier rubyid_x'>x</span><span class='lbracket'>[</span><span class='symbol'>:attributes</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_x'>x</span><span class='rparen'>)</span>
|
413
|
+
<span class='kw'>end</span>
|
414
|
+
|
415
|
+
<span class='id identifier rubyid_associate_children'>associate_children</span><span class='lparen'>(</span><span class='id identifier rubyid_persisted'>persisted</span><span class='comma'>,</span> <span class='id identifier rubyid_children'>children</span><span class='rparen'>)</span>
|
416
|
+
<span class='id identifier rubyid_persisted'>persisted</span> <span class='kw'>unless</span> <span class='ivar'>@meta</span><span class='lbracket'>[</span><span class='symbol'>:method</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='symbol'>:destroy</span>
|
417
|
+
<span class='kw'>end</span></pre>
|
418
|
+
</td>
|
419
|
+
</tr>
|
420
|
+
</table>
|
421
|
+
</div>
|
422
|
+
|
423
|
+
</div>
|
424
|
+
|
425
|
+
</div>
|
426
|
+
|
427
|
+
<div id="footer">
|
428
|
+
Generated on Fri May 5 15:53:23 2017 by
|
429
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
430
|
+
0.9.9 (ruby-2.3.0).
|
431
|
+
</div>
|
432
|
+
|
433
|
+
</div>
|
434
|
+
</body>
|
435
|
+
</html>
|