jsonapi_compliable 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,212 @@
|
|
|
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::BooleanAttribute
|
|
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::BooleanAttribute";
|
|
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 (B)</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>
|
|
41
|
+
»
|
|
42
|
+
<span class="title">BooleanAttribute</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::BooleanAttribute
|
|
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/boolean_attribute.rb</dd>
|
|
82
|
+
</dl>
|
|
83
|
+
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<h2>Overview</h2><div class="docstring">
|
|
87
|
+
<div class="discussion">
|
|
88
|
+
|
|
89
|
+
<p>Turns ruby ? methods into is_ attributes</p>
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
<div class="tags">
|
|
95
|
+
|
|
96
|
+
<div class="examples">
|
|
97
|
+
<p class="tag_title">Examples:</p>
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
<p class="example_title"><div class='inline'>
|
|
101
|
+
<p>Basic Usage</p>
|
|
102
|
+
</div></p>
|
|
103
|
+
|
|
104
|
+
<pre class="example code"><code><span class='id identifier rubyid_boolean_attribute'>boolean_attribute</span> <span class='symbol'>:active?</span>
|
|
105
|
+
|
|
106
|
+
<span class='comment'># equivalent do
|
|
107
|
+
</span><span class='kw'>def</span> <span class='id identifier rubyid_is_active'>is_active</span>
|
|
108
|
+
<span class='ivar'>@object</span><span class='period'>.</span><span class='id identifier rubyid_active?'>active?</span>
|
|
109
|
+
<span class='kw'>end</span></code></pre>
|
|
110
|
+
|
|
111
|
+
</div>
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
</div><h2>Defined Under Namespace</h2>
|
|
115
|
+
<p class="children">
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="BooleanAttribute/ClassMethods.html" title="JsonapiCompliable::Extensions::BooleanAttribute::ClassMethods (module)">ClassMethods</a></span>
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
</p>
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
<h2>
|
|
133
|
+
Class Method Summary
|
|
134
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
135
|
+
</h2>
|
|
136
|
+
|
|
137
|
+
<ul class="summary">
|
|
138
|
+
|
|
139
|
+
<li class="public ">
|
|
140
|
+
<span class="summary_signature">
|
|
141
|
+
|
|
142
|
+
<a href="#included-class_method" title="included (class method)">.<strong>included</strong>(klass) ⇒ Object </a>
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
</span>
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
157
|
+
|
|
158
|
+
</li>
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
</ul>
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
<div id="class_method_details" class="method_details_list">
|
|
167
|
+
<h2>Class Method Details</h2>
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
<div class="method_details first">
|
|
171
|
+
<h3 class="signature first" id="included-class_method">
|
|
172
|
+
|
|
173
|
+
.<strong>included</strong>(klass) ⇒ <tt>Object</tt>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
</h3><table class="source_code">
|
|
180
|
+
<tr>
|
|
181
|
+
<td>
|
|
182
|
+
<pre class="lines">
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
13
|
|
186
|
+
14
|
|
187
|
+
15</pre>
|
|
188
|
+
</td>
|
|
189
|
+
<td>
|
|
190
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/extensions/boolean_attribute.rb', line 13</span>
|
|
191
|
+
|
|
192
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
|
|
193
|
+
<span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'><span class='object_link'><a href="BooleanAttribute/ClassMethods.html" title="JsonapiCompliable::Extensions::BooleanAttribute::ClassMethods (module)">ClassMethods</a></span></span>
|
|
194
|
+
<span class='kw'>end</span></pre>
|
|
195
|
+
</td>
|
|
196
|
+
</tr>
|
|
197
|
+
</table>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
</div>
|
|
203
|
+
|
|
204
|
+
<div id="footer">
|
|
205
|
+
Generated on Fri May 5 15:53:21 2017 by
|
|
206
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
207
|
+
0.9.9 (ruby-2.3.0).
|
|
208
|
+
</div>
|
|
209
|
+
|
|
210
|
+
</div>
|
|
211
|
+
</body>
|
|
212
|
+
</html>
|
|
@@ -0,0 +1,229 @@
|
|
|
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::BooleanAttribute::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::BooleanAttribute::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="../BooleanAttribute.html" title="JsonapiCompliable::Extensions::BooleanAttribute (module)">BooleanAttribute</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::BooleanAttribute::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/boolean_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="#boolean_attribute-instance_method" title="#boolean_attribute (instance method)">#<strong>boolean_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'>
|
|
119
|
+
<p>Register a boolean attribute.</p>
|
|
120
|
+
</div></span>
|
|
121
|
+
|
|
122
|
+
</li>
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
</ul>
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
<div id="instance_method_details" class="method_details_list">
|
|
131
|
+
<h2>Instance Method Details</h2>
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
<div class="method_details first">
|
|
135
|
+
<h3 class="signature first" id="boolean_attribute-instance_method">
|
|
136
|
+
|
|
137
|
+
#<strong>boolean_attribute</strong>(name, options = {}, &blk) ⇒ <tt>Object</tt>
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
</h3><div class="docstring">
|
|
144
|
+
<div class="discussion">
|
|
145
|
+
|
|
146
|
+
<p>Register a boolean attribute</p>
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
<div class="tags">
|
|
152
|
+
<p class="tag_title">Parameters:</p>
|
|
153
|
+
<ul class="param">
|
|
154
|
+
|
|
155
|
+
<li>
|
|
156
|
+
|
|
157
|
+
<span class='name'>name</span>
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
<span class='type'></span>
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
—
|
|
165
|
+
<div class='inline'>
|
|
166
|
+
<p>the corresponding ? method</p>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
</li>
|
|
170
|
+
|
|
171
|
+
<li>
|
|
172
|
+
|
|
173
|
+
<span class='name'>options</span>
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
<em class="default">(defaults to: <tt>{}</tt>)</em>
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
—
|
|
183
|
+
<div class='inline'>
|
|
184
|
+
<p>Normal .attribute options</p>
|
|
185
|
+
</div>
|
|
186
|
+
|
|
187
|
+
</li>
|
|
188
|
+
|
|
189
|
+
</ul>
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
</div><table class="source_code">
|
|
193
|
+
<tr>
|
|
194
|
+
<td>
|
|
195
|
+
<pre class="lines">
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
21
|
|
199
|
+
22
|
|
200
|
+
23
|
|
201
|
+
24
|
|
202
|
+
25</pre>
|
|
203
|
+
</td>
|
|
204
|
+
<td>
|
|
205
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/extensions/boolean_attribute.rb', line 21</span>
|
|
206
|
+
|
|
207
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_boolean_attribute'>boolean_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>
|
|
208
|
+
<span class='id identifier rubyid_blk'>blk</span> <span class='op'>||=</span> <span class='id identifier rubyid_proc'>proc</span> <span class='lbrace'>{</span> <span class='ivar'>@object</span><span class='period'>.</span><span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
|
209
|
+
<span class='id identifier rubyid_field_name'>field_name</span> <span class='op'>=</span> <span class='symbol'>:is_</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>?</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
|
210
|
+
<span class='id identifier rubyid_attribute'>attribute</span> <span class='id identifier rubyid_field_name'>field_name</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span>
|
|
211
|
+
<span class='kw'>end</span></pre>
|
|
212
|
+
</td>
|
|
213
|
+
</tr>
|
|
214
|
+
</table>
|
|
215
|
+
</div>
|
|
216
|
+
|
|
217
|
+
</div>
|
|
218
|
+
|
|
219
|
+
</div>
|
|
220
|
+
|
|
221
|
+
<div id="footer">
|
|
222
|
+
Generated on Fri May 5 15:53:21 2017 by
|
|
223
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
224
|
+
0.9.9 (ruby-2.3.0).
|
|
225
|
+
</div>
|
|
226
|
+
|
|
227
|
+
</div>
|
|
228
|
+
</body>
|
|
229
|
+
</html>
|
|
@@ -0,0 +1,242 @@
|
|
|
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
|
|
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";
|
|
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 (E)</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>
|
|
41
|
+
»
|
|
42
|
+
<span class="title">ExtraAttribute</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
|
|
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
|
+
<h2>Overview</h2><div class="docstring">
|
|
87
|
+
<div class="discussion">
|
|
88
|
+
|
|
89
|
+
<p>Only render a given attribute when the user specifically requests it.
|
|
90
|
+
Useful for computationally-expensive attributes that are not required on
|
|
91
|
+
every request.</p>
|
|
92
|
+
|
|
93
|
+
<p>This class handles the serialization, but you may also want to run code
|
|
94
|
+
during scoping (for instance, to eager load associations referenced by this
|
|
95
|
+
extra attribute. See (Resource.extra_field).</p>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="tags">
|
|
101
|
+
|
|
102
|
+
<div class="examples">
|
|
103
|
+
<p class="tag_title">Examples:</p>
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
<p class="example_title"><div class='inline'>
|
|
107
|
+
<p>Basic Usage</p>
|
|
108
|
+
</div></p>
|
|
109
|
+
|
|
110
|
+
<pre class="example code"><code><span class='comment'># Will only be rendered on user request, ie
|
|
111
|
+
</span><span class='comment'># /people?extra_fields[people]=net_worth
|
|
112
|
+
</span><span class='id identifier rubyid_extra_attribute'>extra_attribute</span> <span class='symbol'>:net_worth</span></code></pre>
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
<p class="example_title"><div class='inline'>
|
|
116
|
+
<p>Eager Loading</p>
|
|
117
|
+
</div></p>
|
|
118
|
+
|
|
119
|
+
<pre class="example code"><code><span class='kw'>class</span> <span class='const'>PersonResource</span> <span class='op'><</span> <span class='const'>ApplicationResource</span>
|
|
120
|
+
<span class='comment'># If the user requests the 'net_worth' attribute, make sure
|
|
121
|
+
</span> <span class='comment'># 'assets' are eager loaded
|
|
122
|
+
</span> <span class='id identifier rubyid_extra_field'>extra_field</span> <span class='symbol'>:net_worth</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_scope'>scope</span><span class='op'>|</span>
|
|
123
|
+
<span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_includes'>includes</span><span class='lparen'>(</span><span class='symbol'>:assets</span><span class='rparen'>)</span>
|
|
124
|
+
<span class='kw'>end</span>
|
|
125
|
+
<span class='kw'>end</span>
|
|
126
|
+
|
|
127
|
+
<span class='kw'>class</span> <span class='const'>SerializablePerson</span> <span class='op'><</span> <span class='const'>JSONAPI</span><span class='op'>::</span><span class='const'>Serializable</span><span class='op'>::</span><span class='const'>Resource</span>
|
|
128
|
+
<span class='comment'># ... code ...
|
|
129
|
+
</span> <span class='id identifier rubyid_extra_attribute'>extra_attribute</span> <span class='symbol'>:net_worth</span> <span class='kw'>do</span>
|
|
130
|
+
<span class='ivar'>@object</span><span class='period'>.</span><span class='id identifier rubyid_assets'>assets</span><span class='period'>.</span><span class='id identifier rubyid_sum'>sum</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:value</span><span class='rparen'>)</span>
|
|
131
|
+
<span class='kw'>end</span>
|
|
132
|
+
<span class='kw'>end</span></code></pre>
|
|
133
|
+
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
<p class="tag_title">See Also:</p>
|
|
138
|
+
<ul class="see">
|
|
139
|
+
|
|
140
|
+
<li><span class='object_link'><a href="../Resource.html#extra_field-class_method" title="JsonapiCompliable::Resource.extra_field (method)">Resource.extra_field</a></span></li>
|
|
141
|
+
|
|
142
|
+
</ul>
|
|
143
|
+
|
|
144
|
+
</div><h2>Defined Under Namespace</h2>
|
|
145
|
+
<p class="children">
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="ExtraAttribute/ClassMethods.html" title="JsonapiCompliable::Extensions::ExtraAttribute::ClassMethods (module)">ClassMethods</a></span>
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
</p>
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
<h2>
|
|
163
|
+
Class Method Summary
|
|
164
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
165
|
+
</h2>
|
|
166
|
+
|
|
167
|
+
<ul class="summary">
|
|
168
|
+
|
|
169
|
+
<li class="public ">
|
|
170
|
+
<span class="summary_signature">
|
|
171
|
+
|
|
172
|
+
<a href="#included-class_method" title="included (class method)">.<strong>included</strong>(klass) ⇒ Object </a>
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
</span>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
187
|
+
|
|
188
|
+
</li>
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
</ul>
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
<div id="class_method_details" class="method_details_list">
|
|
197
|
+
<h2>Class Method Details</h2>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<div class="method_details first">
|
|
201
|
+
<h3 class="signature first" id="included-class_method">
|
|
202
|
+
|
|
203
|
+
.<strong>included</strong>(klass) ⇒ <tt>Object</tt>
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
</h3><table class="source_code">
|
|
210
|
+
<tr>
|
|
211
|
+
<td>
|
|
212
|
+
<pre class="lines">
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
36
|
|
216
|
+
37
|
|
217
|
+
38</pre>
|
|
218
|
+
</td>
|
|
219
|
+
<td>
|
|
220
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/extensions/extra_attribute.rb', line 36</span>
|
|
221
|
+
|
|
222
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span>
|
|
223
|
+
<span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'><span class='object_link'><a href="ExtraAttribute/ClassMethods.html" title="JsonapiCompliable::Extensions::ExtraAttribute::ClassMethods (module)">ClassMethods</a></span></span>
|
|
224
|
+
<span class='kw'>end</span></pre>
|
|
225
|
+
</td>
|
|
226
|
+
</tr>
|
|
227
|
+
</table>
|
|
228
|
+
</div>
|
|
229
|
+
|
|
230
|
+
</div>
|
|
231
|
+
|
|
232
|
+
</div>
|
|
233
|
+
|
|
234
|
+
<div id="footer">
|
|
235
|
+
Generated on Fri May 5 15:53:21 2017 by
|
|
236
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
237
|
+
0.9.9 (ruby-2.3.0).
|
|
238
|
+
</div>
|
|
239
|
+
|
|
240
|
+
</div>
|
|
241
|
+
</body>
|
|
242
|
+
</html>
|