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,237 @@
|
|
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::Extensions::ExtraAttribute::ClassMethods
|
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::Extensions::ExtraAttribute::ClassMethods";
|
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 (C)</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="../../Extensions.html" title="JsonapiCompliable::Extensions (module)">Extensions</a></span></span> » <span class='title'><span class='object_link'><a href="../ExtraAttribute.html" title="JsonapiCompliable::Extensions::ExtraAttribute (module)">ExtraAttribute</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ClassMethods</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::Extensions::ExtraAttribute::ClassMethods
|
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/extra_attribute.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="#extra_attribute-instance_method" title="#extra_attribute (instance method)">#<strong>extra_attribute</strong>(name, options = {}, &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
|
+
</ul>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<div id="instance_method_details" class="method_details_list">
|
129
|
+
<h2>Instance Method Details</h2>
|
130
|
+
|
131
|
+
|
132
|
+
<div class="method_details first">
|
133
|
+
<h3 class="signature first" id="extra_attribute-instance_method">
|
134
|
+
|
135
|
+
#<strong>extra_attribute</strong>(name, options = {}, &blk) ⇒ <tt>Object</tt>
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
</h3><div class="docstring">
|
142
|
+
<div class="discussion">
|
143
|
+
|
144
|
+
|
145
|
+
</div>
|
146
|
+
</div>
|
147
|
+
<div class="tags">
|
148
|
+
<p class="tag_title">Parameters:</p>
|
149
|
+
<ul class="param">
|
150
|
+
|
151
|
+
<li>
|
152
|
+
|
153
|
+
<span class='name'>name</span>
|
154
|
+
|
155
|
+
|
156
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
—
|
161
|
+
<div class='inline'>
|
162
|
+
<p>the name of the attribute</p>
|
163
|
+
</div>
|
164
|
+
|
165
|
+
</li>
|
166
|
+
|
167
|
+
<li>
|
168
|
+
|
169
|
+
<span class='name'>options</span>
|
170
|
+
|
171
|
+
|
172
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
173
|
+
|
174
|
+
|
175
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
176
|
+
|
177
|
+
|
178
|
+
—
|
179
|
+
<div class='inline'>
|
180
|
+
<p>the options passed on to vanilla to .attribute</p>
|
181
|
+
</div>
|
182
|
+
|
183
|
+
</li>
|
184
|
+
|
185
|
+
</ul>
|
186
|
+
|
187
|
+
|
188
|
+
</div><table class="source_code">
|
189
|
+
<tr>
|
190
|
+
<td>
|
191
|
+
<pre class="lines">
|
192
|
+
|
193
|
+
|
194
|
+
43
|
195
|
+
44
|
196
|
+
45
|
197
|
+
46
|
198
|
+
47
|
199
|
+
48
|
200
|
+
49
|
201
|
+
50
|
202
|
+
51
|
203
|
+
52
|
204
|
+
53</pre>
|
205
|
+
</td>
|
206
|
+
<td>
|
207
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/extensions/extra_attribute.rb', line 43</span>
|
208
|
+
|
209
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_extra_attribute'>extra_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
210
|
+
<span class='id identifier rubyid_allow_field'>allow_field</span> <span class='op'>=</span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span>
|
211
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:if</span><span class='rbracket'>]</span>
|
212
|
+
<span class='kw'>next</span> <span class='kw'>false</span> <span class='kw'>unless</span> <span class='id identifier rubyid_instance_eval'>instance_eval</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:if</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
213
|
+
<span class='kw'>end</span>
|
214
|
+
|
215
|
+
<span class='ivar'>@extra_fields</span><span class='lbracket'>[</span><span class='ivar'>@_type</span><span class='rbracket'>]</span> <span class='op'>&&</span> <span class='ivar'>@extra_fields</span><span class='lbracket'>[</span><span class='ivar'>@_type</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
216
|
+
<span class='rbrace'>}</span>
|
217
|
+
|
218
|
+
<span class='id identifier rubyid_attribute'>attribute</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>if:</span> <span class='id identifier rubyid_allow_field'>allow_field</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span>
|
219
|
+
<span class='kw'>end</span></pre>
|
220
|
+
</td>
|
221
|
+
</tr>
|
222
|
+
</table>
|
223
|
+
</div>
|
224
|
+
|
225
|
+
</div>
|
226
|
+
|
227
|
+
</div>
|
228
|
+
|
229
|
+
<div id="footer">
|
230
|
+
Generated on Fri May 5 15:53:21 2017 by
|
231
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
232
|
+
0.9.9 (ruby-2.3.0).
|
233
|
+
</div>
|
234
|
+
|
235
|
+
</div>
|
236
|
+
</body>
|
237
|
+
</html>
|
@@ -0,0 +1,1099 @@
|
|
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::Query
|
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::Query";
|
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 (Q)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Query</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::Query
|
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::Query</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/query.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="#params-instance_method" title="#params (instance method)">#<strong>params</strong> ⇒ Object </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>TODO: This class could use some refactoring love!.</p>
|
133
|
+
</div></span>
|
134
|
+
|
135
|
+
</li>
|
136
|
+
|
137
|
+
|
138
|
+
<li class="public ">
|
139
|
+
<span class="summary_signature">
|
140
|
+
|
141
|
+
<a href="#resource-instance_method" title="#resource (instance method)">#<strong>resource</strong> ⇒ Object </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>TODO: This class could use some refactoring love!.</p>
|
162
|
+
</div></span>
|
163
|
+
|
164
|
+
</li>
|
165
|
+
|
166
|
+
|
167
|
+
</ul>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
<h2>
|
174
|
+
Class Method Summary
|
175
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
176
|
+
</h2>
|
177
|
+
|
178
|
+
<ul class="summary">
|
179
|
+
|
180
|
+
<li class="public ">
|
181
|
+
<span class="summary_signature">
|
182
|
+
|
183
|
+
<a href="#default_hash-class_method" title="default_hash (class method)">.<strong>default_hash</strong> ⇒ Hash </a>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
</span>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
<span class="private note title">private</span>
|
195
|
+
|
196
|
+
|
197
|
+
<span class="summary_desc"><div class='inline'>
|
198
|
+
<p>This is the structure of <tt>Query#to_hash</tt> used elsewhere in the library.</p>
|
199
|
+
</div></span>
|
200
|
+
|
201
|
+
</li>
|
202
|
+
|
203
|
+
|
204
|
+
</ul>
|
205
|
+
|
206
|
+
<h2>
|
207
|
+
Instance Method Summary
|
208
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
209
|
+
</h2>
|
210
|
+
|
211
|
+
<ul class="summary">
|
212
|
+
|
213
|
+
<li class="public ">
|
214
|
+
<span class="summary_signature">
|
215
|
+
|
216
|
+
<a href="#association_names-instance_method" title="#association_names (instance method)">#<strong>association_names</strong> ⇒ Array<Symbol> </a>
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
</span>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
<span class="summary_desc"><div class='inline'>
|
231
|
+
<p>All the keys of the #include_hash.</p>
|
232
|
+
</div></span>
|
233
|
+
|
234
|
+
</li>
|
235
|
+
|
236
|
+
|
237
|
+
<li class="public ">
|
238
|
+
<span class="summary_signature">
|
239
|
+
|
240
|
+
<a href="#include_directive-instance_method" title="#include_directive (instance method)">#<strong>include_directive</strong> ⇒ JSONAPI::IncludeDirective </a>
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
</span>
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
<span class="summary_desc"><div class='inline'>
|
255
|
+
<p>The relevant include directive.</p>
|
256
|
+
</div></span>
|
257
|
+
|
258
|
+
</li>
|
259
|
+
|
260
|
+
|
261
|
+
<li class="public ">
|
262
|
+
<span class="summary_signature">
|
263
|
+
|
264
|
+
<a href="#include_hash-instance_method" title="#include_hash (instance method)">#<strong>include_hash</strong> ⇒ Hash </a>
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
</span>
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
<span class="summary_desc"><div class='inline'>
|
279
|
+
<p>The include, directive, as a hash.</p>
|
280
|
+
</div></span>
|
281
|
+
|
282
|
+
</li>
|
283
|
+
|
284
|
+
|
285
|
+
<li class="public ">
|
286
|
+
<span class="summary_signature">
|
287
|
+
|
288
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(resource, params) ⇒ Query </a>
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
</span>
|
293
|
+
|
294
|
+
|
295
|
+
<span class="note title constructor">constructor</span>
|
296
|
+
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
<span class="summary_desc"><div class='inline'>
|
305
|
+
<p>A new instance of Query.</p>
|
306
|
+
</div></span>
|
307
|
+
|
308
|
+
</li>
|
309
|
+
|
310
|
+
|
311
|
+
<li class="public ">
|
312
|
+
<span class="summary_signature">
|
313
|
+
|
314
|
+
<a href="#to_hash-instance_method" title="#to_hash (instance method)">#<strong>to_hash</strong> ⇒ Hash </a>
|
315
|
+
|
316
|
+
|
317
|
+
|
318
|
+
</span>
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
<span class="summary_desc"><div class='inline'>
|
329
|
+
<p>A flat hash of sanitized query parameters.</p>
|
330
|
+
</div></span>
|
331
|
+
|
332
|
+
</li>
|
333
|
+
|
334
|
+
|
335
|
+
<li class="public ">
|
336
|
+
<span class="summary_signature">
|
337
|
+
|
338
|
+
<a href="#zero_results%3F-instance_method" title="#zero_results? (instance method)">#<strong>zero_results?</strong> ⇒ Boolean </a>
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
</span>
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
<span class="summary_desc"><div class='inline'>
|
353
|
+
<p>Check if the user has requested 0 actual results They may have done this to
|
354
|
+
get, say, the total count without the overhead of fetching actual records.</p>
|
355
|
+
</div></span>
|
356
|
+
|
357
|
+
</li>
|
358
|
+
|
359
|
+
|
360
|
+
</ul>
|
361
|
+
|
362
|
+
|
363
|
+
<div id="constructor_details" class="method_details_list">
|
364
|
+
<h2>Constructor Details</h2>
|
365
|
+
|
366
|
+
<div class="method_details first">
|
367
|
+
<h3 class="signature first" id="initialize-instance_method">
|
368
|
+
|
369
|
+
#<strong>initialize</strong>(resource, params) ⇒ <tt><span class='object_link'><a href="" title="JsonapiCompliable::Query (class)">Query</a></span></tt>
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
</h3><div class="docstring">
|
376
|
+
<div class="discussion">
|
377
|
+
|
378
|
+
<p>Returns a new instance of Query</p>
|
379
|
+
|
380
|
+
|
381
|
+
</div>
|
382
|
+
</div>
|
383
|
+
<div class="tags">
|
384
|
+
|
385
|
+
|
386
|
+
</div><table class="source_code">
|
387
|
+
<tr>
|
388
|
+
<td>
|
389
|
+
<pre class="lines">
|
390
|
+
|
391
|
+
|
392
|
+
24
|
393
|
+
25
|
394
|
+
26
|
395
|
+
27</pre>
|
396
|
+
</td>
|
397
|
+
<td>
|
398
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 24</span>
|
399
|
+
|
400
|
+
<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_params'>params</span><span class='rparen'>)</span>
|
401
|
+
<span class='ivar'>@resource</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span>
|
402
|
+
<span class='ivar'>@params</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span>
|
403
|
+
<span class='kw'>end</span></pre>
|
404
|
+
</td>
|
405
|
+
</tr>
|
406
|
+
</table>
|
407
|
+
</div>
|
408
|
+
|
409
|
+
</div>
|
410
|
+
|
411
|
+
<div id="instance_attr_details" class="attr_details">
|
412
|
+
<h2>Instance Attribute Details</h2>
|
413
|
+
|
414
|
+
|
415
|
+
<span id=""></span>
|
416
|
+
<div class="method_details first">
|
417
|
+
<h3 class="signature first" id="params-instance_method">
|
418
|
+
|
419
|
+
#<strong>params</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
</h3><div class="docstring">
|
426
|
+
<div class="discussion">
|
427
|
+
|
428
|
+
<p>TODO: This class could use some refactoring love!</p>
|
429
|
+
|
430
|
+
|
431
|
+
</div>
|
432
|
+
</div>
|
433
|
+
<div class="tags">
|
434
|
+
|
435
|
+
|
436
|
+
</div><table class="source_code">
|
437
|
+
<tr>
|
438
|
+
<td>
|
439
|
+
<pre class="lines">
|
440
|
+
|
441
|
+
|
442
|
+
4
|
443
|
+
5
|
444
|
+
6</pre>
|
445
|
+
</td>
|
446
|
+
<td>
|
447
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 4</span>
|
448
|
+
|
449
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_params'>params</span>
|
450
|
+
<span class='ivar'>@params</span>
|
451
|
+
<span class='kw'>end</span></pre>
|
452
|
+
</td>
|
453
|
+
</tr>
|
454
|
+
</table>
|
455
|
+
</div>
|
456
|
+
|
457
|
+
|
458
|
+
<span id=""></span>
|
459
|
+
<div class="method_details ">
|
460
|
+
<h3 class="signature " id="resource-instance_method">
|
461
|
+
|
462
|
+
#<strong>resource</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
</h3><div class="docstring">
|
469
|
+
<div class="discussion">
|
470
|
+
|
471
|
+
<p>TODO: This class could use some refactoring love!</p>
|
472
|
+
|
473
|
+
|
474
|
+
</div>
|
475
|
+
</div>
|
476
|
+
<div class="tags">
|
477
|
+
|
478
|
+
|
479
|
+
</div><table class="source_code">
|
480
|
+
<tr>
|
481
|
+
<td>
|
482
|
+
<pre class="lines">
|
483
|
+
|
484
|
+
|
485
|
+
4
|
486
|
+
5
|
487
|
+
6</pre>
|
488
|
+
</td>
|
489
|
+
<td>
|
490
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 4</span>
|
491
|
+
|
492
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_resource'>resource</span>
|
493
|
+
<span class='ivar'>@resource</span>
|
494
|
+
<span class='kw'>end</span></pre>
|
495
|
+
</td>
|
496
|
+
</tr>
|
497
|
+
</table>
|
498
|
+
</div>
|
499
|
+
|
500
|
+
</div>
|
501
|
+
|
502
|
+
|
503
|
+
<div id="class_method_details" class="method_details_list">
|
504
|
+
<h2>Class Method Details</h2>
|
505
|
+
|
506
|
+
|
507
|
+
<div class="method_details first">
|
508
|
+
<h3 class="signature first" id="default_hash-class_method">
|
509
|
+
|
510
|
+
.<strong>default_hash</strong> ⇒ <tt>Hash</tt>
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
|
516
|
+
</h3><div class="docstring">
|
517
|
+
<div class="discussion">
|
518
|
+
<p class="note private">
|
519
|
+
<strong>This method is part of a private API.</strong>
|
520
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
521
|
+
</p>
|
522
|
+
|
523
|
+
<p>This is the structure of <tt>Query#to_hash</tt> used elsewhere in the library</p>
|
524
|
+
|
525
|
+
|
526
|
+
</div>
|
527
|
+
</div>
|
528
|
+
<div class="tags">
|
529
|
+
|
530
|
+
<p class="tag_title">Returns:</p>
|
531
|
+
<ul class="return">
|
532
|
+
|
533
|
+
<li>
|
534
|
+
|
535
|
+
|
536
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
—
|
541
|
+
<div class='inline'>
|
542
|
+
<p>the default hash</p>
|
543
|
+
</div>
|
544
|
+
|
545
|
+
</li>
|
546
|
+
|
547
|
+
</ul>
|
548
|
+
|
549
|
+
<p class="tag_title">See Also:</p>
|
550
|
+
<ul class="see">
|
551
|
+
|
552
|
+
<li><span class='object_link'><a href="#to_hash-instance_method" title="JsonapiCompliable::Query#to_hash (method)">#to_hash</a></span></li>
|
553
|
+
|
554
|
+
</ul>
|
555
|
+
|
556
|
+
</div><table class="source_code">
|
557
|
+
<tr>
|
558
|
+
<td>
|
559
|
+
<pre class="lines">
|
560
|
+
|
561
|
+
|
562
|
+
12
|
563
|
+
13
|
564
|
+
14
|
565
|
+
15
|
566
|
+
16
|
567
|
+
17
|
568
|
+
18
|
569
|
+
19
|
570
|
+
20
|
571
|
+
21
|
572
|
+
22</pre>
|
573
|
+
</td>
|
574
|
+
<td>
|
575
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 12</span>
|
576
|
+
|
577
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_default_hash'>default_hash</span>
|
578
|
+
<span class='lbrace'>{</span>
|
579
|
+
<span class='label'>filter:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
580
|
+
<span class='label'>sort:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
581
|
+
<span class='label'>page:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
582
|
+
<span class='label'>include:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
583
|
+
<span class='label'>stats:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
584
|
+
<span class='label'>fields:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span>
|
585
|
+
<span class='label'>extra_fields:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
586
|
+
<span class='rbrace'>}</span>
|
587
|
+
<span class='kw'>end</span></pre>
|
588
|
+
</td>
|
589
|
+
</tr>
|
590
|
+
</table>
|
591
|
+
</div>
|
592
|
+
|
593
|
+
</div>
|
594
|
+
|
595
|
+
<div id="instance_method_details" class="method_details_list">
|
596
|
+
<h2>Instance Method Details</h2>
|
597
|
+
|
598
|
+
|
599
|
+
<div class="method_details first">
|
600
|
+
<h3 class="signature first" id="association_names-instance_method">
|
601
|
+
|
602
|
+
#<strong>association_names</strong> ⇒ <tt>Array<Symbol></tt>
|
603
|
+
|
604
|
+
|
605
|
+
|
606
|
+
|
607
|
+
|
608
|
+
</h3><div class="docstring">
|
609
|
+
<div class="discussion">
|
610
|
+
|
611
|
+
<p>All the keys of the #include_hash</p>
|
612
|
+
|
613
|
+
<p>For example, let's say we had</p>
|
614
|
+
|
615
|
+
<pre class="code ruby"><code class="ruby">{ posts: { comments: {} }</code></pre>
|
616
|
+
|
617
|
+
<p><code>#association_names</code> would return</p>
|
618
|
+
|
619
|
+
<pre class="code ruby"><code class="ruby"><span class='lbracket'>[</span><span class='symbol'>:posts</span><span class='comma'>,</span> <span class='symbol'>:comments</span><span class='rbracket'>]</span>
|
620
|
+
</code></pre>
|
621
|
+
|
622
|
+
|
623
|
+
</div>
|
624
|
+
</div>
|
625
|
+
<div class="tags">
|
626
|
+
|
627
|
+
<p class="tag_title">Returns:</p>
|
628
|
+
<ul class="return">
|
629
|
+
|
630
|
+
<li>
|
631
|
+
|
632
|
+
|
633
|
+
<span class='type'>(<tt>Array<Symbol></tt>)</span>
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
—
|
638
|
+
<div class='inline'>
|
639
|
+
<p>all association names, recursive</p>
|
640
|
+
</div>
|
641
|
+
|
642
|
+
</li>
|
643
|
+
|
644
|
+
</ul>
|
645
|
+
|
646
|
+
</div><table class="source_code">
|
647
|
+
<tr>
|
648
|
+
<td>
|
649
|
+
<pre class="lines">
|
650
|
+
|
651
|
+
|
652
|
+
71
|
653
|
+
72
|
654
|
+
73</pre>
|
655
|
+
</td>
|
656
|
+
<td>
|
657
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 71</span>
|
658
|
+
|
659
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_association_names'>association_names</span>
|
660
|
+
<span class='ivar'>@association_names</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="Util.html" title="JsonapiCompliable::Util (module)">Util</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util/Hash.html" title="JsonapiCompliable::Util::Hash (class)">Hash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_keys'><span class='object_link'><a href="Util/Hash.html#keys-class_method" title="JsonapiCompliable::Util::Hash.keys (method)">keys</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_include_hash'>include_hash</span><span class='rparen'>)</span>
|
661
|
+
<span class='kw'>end</span></pre>
|
662
|
+
</td>
|
663
|
+
</tr>
|
664
|
+
</table>
|
665
|
+
</div>
|
666
|
+
|
667
|
+
<div class="method_details ">
|
668
|
+
<h3 class="signature " id="include_directive-instance_method">
|
669
|
+
|
670
|
+
#<strong>include_directive</strong> ⇒ <tt>JSONAPI::IncludeDirective</tt>
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
|
676
|
+
</h3><div class="docstring">
|
677
|
+
<div class="discussion">
|
678
|
+
|
679
|
+
<p>The relevant include directive</p>
|
680
|
+
|
681
|
+
|
682
|
+
</div>
|
683
|
+
</div>
|
684
|
+
<div class="tags">
|
685
|
+
|
686
|
+
<p class="tag_title">Returns:</p>
|
687
|
+
<ul class="return">
|
688
|
+
|
689
|
+
<li>
|
690
|
+
|
691
|
+
|
692
|
+
<span class='type'>(<tt>JSONAPI::IncludeDirective</tt>)</span>
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
</li>
|
697
|
+
|
698
|
+
</ul>
|
699
|
+
|
700
|
+
<p class="tag_title">See Also:</p>
|
701
|
+
<ul class="see">
|
702
|
+
|
703
|
+
<li><a href="http://jsonapi-rb.org" target="_parent" title="http://jsonapi-rb.org">http://jsonapi-rb.org</a></li>
|
704
|
+
|
705
|
+
</ul>
|
706
|
+
|
707
|
+
</div><table class="source_code">
|
708
|
+
<tr>
|
709
|
+
<td>
|
710
|
+
<pre class="lines">
|
711
|
+
|
712
|
+
|
713
|
+
32
|
714
|
+
33
|
715
|
+
34</pre>
|
716
|
+
</td>
|
717
|
+
<td>
|
718
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 32</span>
|
719
|
+
|
720
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_include_directive'>include_directive</span>
|
721
|
+
<span class='ivar'>@include_directive</span> <span class='op'>||=</span> <span class='const'>JSONAPI</span><span class='op'>::</span><span class='const'>IncludeDirective</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:include</span><span class='rbracket'>]</span><span class='rparen'>)</span>
|
722
|
+
<span class='kw'>end</span></pre>
|
723
|
+
</td>
|
724
|
+
</tr>
|
725
|
+
</table>
|
726
|
+
</div>
|
727
|
+
|
728
|
+
<div class="method_details ">
|
729
|
+
<h3 class="signature " id="include_hash-instance_method">
|
730
|
+
|
731
|
+
#<strong>include_hash</strong> ⇒ <tt>Hash</tt>
|
732
|
+
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
</h3><div class="docstring">
|
738
|
+
<div class="discussion">
|
739
|
+
|
740
|
+
<p>The include, directive, as a hash. For instance</p>
|
741
|
+
|
742
|
+
<p>{ posts: { comments: {} } }</p>
|
743
|
+
|
744
|
+
<p>This will only include relationships that are</p>
|
745
|
+
<ul><li>
|
746
|
+
<p>Available on the Resource</p>
|
747
|
+
</li><li>
|
748
|
+
<p>Whitelisted (when specified)</p>
|
749
|
+
</li></ul>
|
750
|
+
|
751
|
+
<p>So that users can't simply request your entire object graph.</p>
|
752
|
+
|
753
|
+
|
754
|
+
</div>
|
755
|
+
</div>
|
756
|
+
<div class="tags">
|
757
|
+
|
758
|
+
<p class="tag_title">Returns:</p>
|
759
|
+
<ul class="return">
|
760
|
+
|
761
|
+
<li>
|
762
|
+
|
763
|
+
|
764
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
765
|
+
|
766
|
+
|
767
|
+
|
768
|
+
—
|
769
|
+
<div class='inline'>
|
770
|
+
<p>the scrubbed include directive as a hash</p>
|
771
|
+
</div>
|
772
|
+
|
773
|
+
</li>
|
774
|
+
|
775
|
+
</ul>
|
776
|
+
|
777
|
+
<p class="tag_title">See Also:</p>
|
778
|
+
<ul class="see">
|
779
|
+
|
780
|
+
<li><span class='object_link'><a href="Util/IncludeParams.html" title="JsonapiCompliable::Util::IncludeParams (class)">Util::IncludeParams</a></span></li>
|
781
|
+
|
782
|
+
</ul>
|
783
|
+
|
784
|
+
</div><table class="source_code">
|
785
|
+
<tr>
|
786
|
+
<td>
|
787
|
+
<pre class="lines">
|
788
|
+
|
789
|
+
|
790
|
+
49
|
791
|
+
50
|
792
|
+
51
|
793
|
+
52
|
794
|
+
53
|
795
|
+
54
|
796
|
+
55
|
797
|
+
56
|
798
|
+
57
|
799
|
+
58</pre>
|
800
|
+
</td>
|
801
|
+
<td>
|
802
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 49</span>
|
803
|
+
|
804
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_include_hash'>include_hash</span>
|
805
|
+
<span class='ivar'>@include_hash</span> <span class='op'>||=</span> <span class='kw'>begin</span>
|
806
|
+
<span class='id identifier rubyid_requested'>requested</span> <span class='op'>=</span> <span class='id identifier rubyid_include_directive'>include_directive</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span>
|
807
|
+
<span class='id identifier rubyid_all_allowed'>all_allowed</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_sideloading'>sideloading</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span><span class='lbracket'>[</span><span class='symbol'>:base</span><span class='rbracket'>]</span>
|
808
|
+
<span class='id identifier rubyid_whitelist'>whitelist</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_sideload_whitelist'>sideload_whitelist</span><span class='period'>.</span><span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='symbol'>:merge</span><span class='rparen'>)</span>
|
809
|
+
<span class='id identifier rubyid_allowed'>allowed</span> <span class='op'>=</span> <span class='id identifier rubyid_whitelist'>whitelist</span> <span class='op'>?</span> <span class='const'><span class='object_link'><a href="Util.html" title="JsonapiCompliable::Util (module)">Util</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util/IncludeParams.html" title="JsonapiCompliable::Util::IncludeParams (class)">IncludeParams</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scrub'><span class='object_link'><a href="Util/IncludeParams.html#scrub-class_method" title="JsonapiCompliable::Util::IncludeParams.scrub (method)">scrub</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_all_allowed'>all_allowed</span><span class='comma'>,</span> <span class='id identifier rubyid_whitelist'>whitelist</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_all_allowed'>all_allowed</span>
|
810
|
+
|
811
|
+
<span class='const'><span class='object_link'><a href="Util.html" title="JsonapiCompliable::Util (module)">Util</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util/IncludeParams.html" title="JsonapiCompliable::Util::IncludeParams (class)">IncludeParams</a></span></span><span class='period'>.</span><span class='id identifier rubyid_scrub'><span class='object_link'><a href="Util/IncludeParams.html#scrub-class_method" title="JsonapiCompliable::Util::IncludeParams.scrub (method)">scrub</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_requested'>requested</span><span class='comma'>,</span> <span class='id identifier rubyid_allowed'>allowed</span><span class='rparen'>)</span>
|
812
|
+
<span class='kw'>end</span>
|
813
|
+
<span class='kw'>end</span></pre>
|
814
|
+
</td>
|
815
|
+
</tr>
|
816
|
+
</table>
|
817
|
+
</div>
|
818
|
+
|
819
|
+
<div class="method_details ">
|
820
|
+
<h3 class="signature " id="to_hash-instance_method">
|
821
|
+
|
822
|
+
#<strong>to_hash</strong> ⇒ <tt>Hash</tt>
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
|
828
|
+
</h3><div class="docstring">
|
829
|
+
<div class="discussion">
|
830
|
+
|
831
|
+
<p>A flat hash of sanitized query parameters. All relationship names are
|
832
|
+
top-level:</p>
|
833
|
+
|
834
|
+
<pre class="code ruby"><code class="ruby">{
|
835
|
+
posts: { filter, sort, ... }
|
836
|
+
comments: { filter, sort, ... }
|
837
|
+
}</code></pre>
|
838
|
+
|
839
|
+
|
840
|
+
</div>
|
841
|
+
</div>
|
842
|
+
<div class="tags">
|
843
|
+
|
844
|
+
<div class="examples">
|
845
|
+
<p class="tag_title">Examples:</p>
|
846
|
+
|
847
|
+
|
848
|
+
<p class="example_title"><div class='inline'>
|
849
|
+
<p>sorting</p>
|
850
|
+
</div></p>
|
851
|
+
|
852
|
+
<pre class="example code"><code><span class='comment'># GET /posts?sort=-title
|
853
|
+
</span><span class='lbrace'>{</span> <span class='label'>posts:</span> <span class='lbrace'>{</span> <span class='label'>sort:</span> <span class='lbrace'>{</span> <span class='label'>title:</span> <span class='symbol'>:desc</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span></code></pre>
|
854
|
+
|
855
|
+
|
856
|
+
<p class="example_title"><div class='inline'>
|
857
|
+
<p>pagination</p>
|
858
|
+
</div></p>
|
859
|
+
|
860
|
+
<pre class="example code"><code># GET /posts?page[number]=2&page[size]=10
|
861
|
+
{ posts: { page: { number: 2, size: 10 } }</code></pre>
|
862
|
+
|
863
|
+
|
864
|
+
<p class="example_title"><div class='inline'>
|
865
|
+
<p>filtering</p>
|
866
|
+
</div></p>
|
867
|
+
|
868
|
+
<pre class="example code"><code># GET /posts?filter[title]=Foo
|
869
|
+
{ posts: { filter: { title: 'Foo' } }</code></pre>
|
870
|
+
|
871
|
+
|
872
|
+
<p class="example_title"><div class='inline'>
|
873
|
+
<p>include</p>
|
874
|
+
</div></p>
|
875
|
+
|
876
|
+
<pre class="example code"><code><span class='comment'># GET /posts?include=comments.author
|
877
|
+
</span><span class='lbrace'>{</span> <span class='label'>posts:</span> <span class='lbrace'>{</span> <span class='label'>include:</span> <span class='lbrace'>{</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> <span class='rbrace'>}</span> <span class='rbrace'>}</span></code></pre>
|
878
|
+
|
879
|
+
|
880
|
+
<p class="example_title"><div class='inline'>
|
881
|
+
<p>stats</p>
|
882
|
+
</div></p>
|
883
|
+
|
884
|
+
<pre class="example code"><code><span class='comment'># GET /posts?stats[likes]=count,average
|
885
|
+
</span><span class='lbrace'>{</span> <span class='label'>posts:</span> <span class='lbrace'>{</span> <span class='label'>stats:</span> <span class='lbracket'>[</span><span class='symbol'>:count</span><span class='comma'>,</span> <span class='symbol'>:average</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span></code></pre>
|
886
|
+
|
887
|
+
|
888
|
+
<p class="example_title"><div class='inline'>
|
889
|
+
<p>fields</p>
|
890
|
+
</div></p>
|
891
|
+
|
892
|
+
<pre class="example code"><code><span class='comment'># GET /posts?fields=foo,bar
|
893
|
+
</span><span class='lbrace'>{</span> <span class='label'>posts:</span> <span class='lbrace'>{</span> <span class='label'>fields:</span> <span class='lbracket'>[</span><span class='symbol'>:foo</span><span class='comma'>,</span> <span class='symbol'>:bar</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span></code></pre>
|
894
|
+
|
895
|
+
|
896
|
+
<p class="example_title"><div class='inline'>
|
897
|
+
<p>extra fields</p>
|
898
|
+
</div></p>
|
899
|
+
|
900
|
+
<pre class="example code"><code><span class='comment'># GET /posts?fields=foo,bar
|
901
|
+
</span><span class='lbrace'>{</span> <span class='label'>posts:</span> <span class='lbrace'>{</span> <span class='label'>extra_fields:</span> <span class='lbracket'>[</span><span class='symbol'>:foo</span><span class='comma'>,</span> <span class='symbol'>:bar</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span></code></pre>
|
902
|
+
|
903
|
+
|
904
|
+
<p class="example_title"><div class='inline'>
|
905
|
+
<p>nested parameters</p>
|
906
|
+
</div></p>
|
907
|
+
|
908
|
+
<pre class="example code"><code># GET /posts?include=comments&sort=comments.created_at&page[comments][size]=3
|
909
|
+
{
|
910
|
+
posts: { ... },
|
911
|
+
comments: { page: { size: 3 }, sort: { created_at: :asc } }</code></pre>
|
912
|
+
|
913
|
+
</div>
|
914
|
+
|
915
|
+
<p class="tag_title">Returns:</p>
|
916
|
+
<ul class="return">
|
917
|
+
|
918
|
+
<li>
|
919
|
+
|
920
|
+
|
921
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
922
|
+
|
923
|
+
|
924
|
+
|
925
|
+
—
|
926
|
+
<div class='inline'>
|
927
|
+
<p>the normalized query hash</p>
|
928
|
+
</div>
|
929
|
+
|
930
|
+
</li>
|
931
|
+
|
932
|
+
</ul>
|
933
|
+
|
934
|
+
<p class="tag_title">See Also:</p>
|
935
|
+
<ul class="see">
|
936
|
+
|
937
|
+
<li>#default_hash</li>
|
938
|
+
|
939
|
+
<li><span class='object_link'><a href="Base.html#query_hash-instance_method" title="JsonapiCompliable::Base#query_hash (method)">Base#query_hash</a></span></li>
|
940
|
+
|
941
|
+
</ul>
|
942
|
+
|
943
|
+
</div><table class="source_code">
|
944
|
+
<tr>
|
945
|
+
<td>
|
946
|
+
<pre class="lines">
|
947
|
+
|
948
|
+
|
949
|
+
120
|
950
|
+
121
|
951
|
+
122
|
952
|
+
123
|
953
|
+
124
|
954
|
+
125
|
955
|
+
126
|
956
|
+
127
|
957
|
+
128
|
958
|
+
129
|
959
|
+
130
|
960
|
+
131
|
961
|
+
132
|
962
|
+
133
|
963
|
+
134
|
964
|
+
135
|
965
|
+
136
|
966
|
+
137
|
967
|
+
138
|
968
|
+
139
|
969
|
+
140
|
970
|
+
141
|
971
|
+
142</pre>
|
972
|
+
</td>
|
973
|
+
<td>
|
974
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 120</span>
|
975
|
+
|
976
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_to_hash'>to_hash</span>
|
977
|
+
<span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='lbrace'>{</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span> <span class='op'>=></span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_default_hash'>default_hash</span> <span class='rbrace'>}</span>
|
978
|
+
|
979
|
+
<span class='id identifier rubyid_association_names'>association_names</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_name'>name</span><span class='op'>|</span>
|
980
|
+
<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='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_default_hash'>default_hash</span>
|
981
|
+
<span class='kw'>end</span>
|
982
|
+
|
983
|
+
<span class='id identifier rubyid_fields'>fields</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_fields'>parse_fields</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:fields</span><span class='rparen'>)</span>
|
984
|
+
<span class='id identifier rubyid_extra_fields'>extra_fields</span> <span class='op'>=</span> <span class='id identifier rubyid_parse_fields'>parse_fields</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='symbol'>:extra_fields</span><span class='rparen'>)</span>
|
985
|
+
<span class='id identifier rubyid_hash'>hash</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_query_hash'>query_hash</span><span class='op'>|</span>
|
986
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:fields</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_fields'>fields</span>
|
987
|
+
<span class='id identifier rubyid_hash'>hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:extra_fields</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_extra_fields'>extra_fields</span>
|
988
|
+
<span class='kw'>end</span>
|
989
|
+
|
990
|
+
<span class='id identifier rubyid_parse_filter'>parse_filter</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
991
|
+
<span class='id identifier rubyid_parse_sort'>parse_sort</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
992
|
+
<span class='id identifier rubyid_parse_pagination'>parse_pagination</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
993
|
+
|
994
|
+
<span class='id identifier rubyid_parse_include'>parse_include</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_include_hash'>include_hash</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='rparen'>)</span>
|
995
|
+
<span class='id identifier rubyid_parse_stats'>parse_stats</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
996
|
+
|
997
|
+
<span class='id identifier rubyid_hash'>hash</span>
|
998
|
+
<span class='kw'>end</span></pre>
|
999
|
+
</td>
|
1000
|
+
</tr>
|
1001
|
+
</table>
|
1002
|
+
</div>
|
1003
|
+
|
1004
|
+
<div class="method_details ">
|
1005
|
+
<h3 class="signature " id="zero_results?-instance_method">
|
1006
|
+
|
1007
|
+
#<strong>zero_results?</strong> ⇒ <tt>Boolean</tt>
|
1008
|
+
|
1009
|
+
|
1010
|
+
|
1011
|
+
|
1012
|
+
|
1013
|
+
</h3><div class="docstring">
|
1014
|
+
<div class="discussion">
|
1015
|
+
|
1016
|
+
<p>Check if the user has requested 0 actual results They may have done this to
|
1017
|
+
get, say, the total count without the overhead of fetching actual records.</p>
|
1018
|
+
|
1019
|
+
|
1020
|
+
</div>
|
1021
|
+
</div>
|
1022
|
+
<div class="tags">
|
1023
|
+
|
1024
|
+
<div class="examples">
|
1025
|
+
<p class="tag_title">Examples:</p>
|
1026
|
+
|
1027
|
+
|
1028
|
+
<p class="example_title"><div class='inline'>
|
1029
|
+
<p>Total Count, 0 Results</p>
|
1030
|
+
</div></p>
|
1031
|
+
|
1032
|
+
<pre class="example code"><code><span class='comment'># GET /posts?page[size]=0&stats[total]=count
|
1033
|
+
</span><span class='comment'># Response:
|
1034
|
+
</span><span class='lbrace'>{</span>
|
1035
|
+
<span class='label'>data:</span> <span class='lbracket'>[</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
1036
|
+
<span class='label'>meta:</span> <span class='lbrace'>{</span>
|
1037
|
+
<span class='label'>stats:</span> <span class='lbrace'>{</span> <span class='label'>total:</span> <span class='lbrace'>{</span> <span class='label'>count:</span> <span class='int'>100</span> <span class='rbrace'>}</span> <span class='rbrace'>}</span>
|
1038
|
+
<span class='rbrace'>}</span>
|
1039
|
+
<span class='rbrace'>}</span></code></pre>
|
1040
|
+
|
1041
|
+
</div>
|
1042
|
+
|
1043
|
+
<p class="tag_title">Returns:</p>
|
1044
|
+
<ul class="return">
|
1045
|
+
|
1046
|
+
<li>
|
1047
|
+
|
1048
|
+
|
1049
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1050
|
+
|
1051
|
+
|
1052
|
+
|
1053
|
+
—
|
1054
|
+
<div class='inline'>
|
1055
|
+
<p>were 0 results requested?</p>
|
1056
|
+
</div>
|
1057
|
+
|
1058
|
+
</li>
|
1059
|
+
|
1060
|
+
</ul>
|
1061
|
+
|
1062
|
+
</div><table class="source_code">
|
1063
|
+
<tr>
|
1064
|
+
<td>
|
1065
|
+
<pre class="lines">
|
1066
|
+
|
1067
|
+
|
1068
|
+
159
|
1069
|
+
160
|
1070
|
+
161
|
1071
|
+
162
|
1072
|
+
163</pre>
|
1073
|
+
</td>
|
1074
|
+
<td>
|
1075
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/query.rb', line 159</span>
|
1076
|
+
|
1077
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_zero_results?'>zero_results?</span>
|
1078
|
+
<span class='op'>!</span><span class='ivar'>@params</span><span class='lbracket'>[</span><span class='symbol'>:page</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span>
|
1079
|
+
<span class='op'>!</span><span class='ivar'>@params</span><span class='lbracket'>[</span><span class='symbol'>:page</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:size</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>&&</span>
|
1080
|
+
<span class='ivar'>@params</span><span class='lbracket'>[</span><span class='symbol'>:page</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:size</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>==</span> <span class='int'>0</span>
|
1081
|
+
<span class='kw'>end</span></pre>
|
1082
|
+
</td>
|
1083
|
+
</tr>
|
1084
|
+
</table>
|
1085
|
+
</div>
|
1086
|
+
|
1087
|
+
</div>
|
1088
|
+
|
1089
|
+
</div>
|
1090
|
+
|
1091
|
+
<div id="footer">
|
1092
|
+
Generated on Fri May 5 15:53:22 2017 by
|
1093
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1094
|
+
0.9.9 (ruby-2.3.0).
|
1095
|
+
</div>
|
1096
|
+
|
1097
|
+
</div>
|
1098
|
+
</body>
|
1099
|
+
</html>
|