jsonapi_compliable 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/docs/Jsonapi/ResourceGenerator.html +1 -1
- data/docs/Jsonapi.html +1 -1
- data/docs/JsonapiCompliable/Adapters/Abstract.html +1 -1
- data/docs/JsonapiCompliable/Adapters/ActiveRecord.html +1 -1
- data/docs/JsonapiCompliable/Adapters/ActiveRecordSideloading.html +1 -1
- data/docs/JsonapiCompliable/Adapters/Null.html +1 -1
- data/docs/JsonapiCompliable/Adapters.html +1 -1
- data/docs/JsonapiCompliable/Base.html +389 -62
- data/docs/JsonapiCompliable/Deserializer.html +1 -1
- data/docs/JsonapiCompliable/Errors/BadFilter.html +1 -1
- data/docs/JsonapiCompliable/Errors/StatNotFound.html +1 -1
- data/docs/JsonapiCompliable/Errors/UnsupportedPageSize.html +1 -1
- data/docs/JsonapiCompliable/Errors/ValidationError.html +1 -1
- data/docs/JsonapiCompliable/Errors.html +1 -1
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute/ClassMethods.html +1 -1
- data/docs/JsonapiCompliable/Extensions/BooleanAttribute.html +1 -1
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute/ClassMethods.html +1 -1
- data/docs/JsonapiCompliable/Extensions/ExtraAttribute.html +1 -1
- data/docs/JsonapiCompliable/Extensions.html +1 -1
- data/docs/JsonapiCompliable/Query.html +27 -21
- data/docs/JsonapiCompliable/Rails.html +1 -1
- data/docs/JsonapiCompliable/Resource.html +189 -572
- data/docs/JsonapiCompliable/Scope.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Base.html +1 -1
- data/docs/JsonapiCompliable/Scoping/DefaultFilter.html +1 -1
- data/docs/JsonapiCompliable/Scoping/ExtraFields.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Filter.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Filterable.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Paginate.html +1 -1
- data/docs/JsonapiCompliable/Scoping/Sort.html +1 -1
- data/docs/JsonapiCompliable/Scoping.html +1 -1
- data/docs/JsonapiCompliable/SerializableTempId.html +1 -1
- data/docs/JsonapiCompliable/Sideload.html +164 -384
- data/docs/JsonapiCompliable/Stats/DSL.html +1 -1
- data/docs/JsonapiCompliable/Stats/Payload.html +1 -1
- data/docs/JsonapiCompliable/Stats.html +1 -1
- data/docs/JsonapiCompliable/Util/FieldParams.html +1 -1
- data/docs/JsonapiCompliable/Util/Hash.html +1 -1
- data/docs/JsonapiCompliable/Util/IncludeParams.html +1 -1
- data/docs/JsonapiCompliable/Util/Persistence.html +1 -1
- data/docs/JsonapiCompliable/Util/RelationshipPayload.html +1 -1
- data/docs/JsonapiCompliable/Util/RenderOptions.html +1 -1
- data/docs/JsonapiCompliable/Util/ValidationResponse.html +1 -1
- data/docs/JsonapiCompliable/Util.html +1 -1
- data/docs/JsonapiCompliable.html +2 -2
- data/docs/_index.html +1 -1
- data/docs/file.README.html +1 -1
- data/docs/index.html +1 -1
- data/docs/method_list.html +191 -215
- data/docs/top-level-namespace.html +1 -1
- data/lib/jsonapi_compliable/base.rb +43 -1
- data/lib/jsonapi_compliable/query.rb +8 -5
- data/lib/jsonapi_compliable/resource.rb +2 -90
- data/lib/jsonapi_compliable/scope.rb +2 -4
- data/lib/jsonapi_compliable/sideload.rb +7 -59
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +2 -2
@@ -137,6 +137,30 @@
|
|
137
137
|
<p>Define your JSONAPI configuration.</p>
|
138
138
|
</div></span>
|
139
139
|
|
140
|
+
</li>
|
141
|
+
|
142
|
+
|
143
|
+
<li class="public ">
|
144
|
+
<span class="summary_signature">
|
145
|
+
|
146
|
+
<a href="#sideload_whitelist-class_method" title="sideload_whitelist (class method)">.<strong>sideload_whitelist</strong>(hash) ⇒ Object </a>
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
</span>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
<span class="summary_desc"><div class='inline'>
|
161
|
+
<p>Set the sideload whitelist.</p>
|
162
|
+
</div></span>
|
163
|
+
|
140
164
|
</li>
|
141
165
|
|
142
166
|
|
@@ -363,6 +387,28 @@ serialized parameters.</p>
|
|
363
387
|
<p>Similar to <tt>render :json</tt> or <tt>render :jsonapi</tt>.</p>
|
364
388
|
</div></span>
|
365
389
|
|
390
|
+
</li>
|
391
|
+
|
392
|
+
|
393
|
+
<li class="public ">
|
394
|
+
<span class="summary_signature">
|
395
|
+
|
396
|
+
<a href="#sideload_whitelist-instance_method" title="#sideload_whitelist (instance method)">#<strong>sideload_whitelist</strong> ⇒ Object </a>
|
397
|
+
|
398
|
+
|
399
|
+
|
400
|
+
</span>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
<span class="private note title">private</span>
|
408
|
+
|
409
|
+
|
410
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
411
|
+
|
366
412
|
</li>
|
367
413
|
|
368
414
|
|
@@ -484,7 +530,6 @@ serialized parameters.</p>
|
|
484
530
|
<pre class="lines">
|
485
531
|
|
486
532
|
|
487
|
-
44
|
488
533
|
45
|
489
534
|
46
|
490
535
|
47
|
@@ -494,10 +539,11 @@ serialized parameters.</p>
|
|
494
539
|
51
|
495
540
|
52
|
496
541
|
53
|
497
|
-
54
|
542
|
+
54
|
543
|
+
55</pre>
|
498
544
|
</td>
|
499
545
|
<td>
|
500
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
546
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 45</span>
|
501
547
|
|
502
548
|
<span class='kw'>def</span> <span class='id identifier rubyid_jsonapi'>jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_foo'>foo</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bar</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
503
549
|
<span class='kw'>if</span> <span class='id identifier rubyid_resource'>resource</span>
|
@@ -513,6 +559,106 @@ serialized parameters.</p>
|
|
513
559
|
</td>
|
514
560
|
</tr>
|
515
561
|
</table>
|
562
|
+
</div>
|
563
|
+
|
564
|
+
<div class="method_details ">
|
565
|
+
<h3 class="signature " id="sideload_whitelist-class_method">
|
566
|
+
|
567
|
+
.<strong>sideload_whitelist</strong>(hash) ⇒ <tt>Object</tt>
|
568
|
+
|
569
|
+
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
</h3><div class="docstring">
|
574
|
+
<div class="discussion">
|
575
|
+
|
576
|
+
<p>Set the sideload whitelist. You may want to omit sideloads for security or
|
577
|
+
performance reasons.</p>
|
578
|
+
|
579
|
+
<p>Uses JSONAPI::IncludeDirective from <a href="{http://jsonapi-rb.org" target="_parent" title="jsonapi-rb">jsonapi-rb</a>}</p>
|
580
|
+
|
581
|
+
|
582
|
+
</div>
|
583
|
+
</div>
|
584
|
+
<div class="tags">
|
585
|
+
|
586
|
+
<div class="examples">
|
587
|
+
<p class="tag_title">Examples:</p>
|
588
|
+
|
589
|
+
|
590
|
+
<p class="example_title"><div class='inline'>
|
591
|
+
<p>Whitelisting Relationships</p>
|
592
|
+
</div></p>
|
593
|
+
|
594
|
+
<pre class="example code"><code><span class='comment'># Given the following whitelist
|
595
|
+
</span><span class='kw'>class</span> <span class='const'>PostsController</span> <span class='op'><</span> <span class='const'>ApplicationResource</span>
|
596
|
+
<span class='id identifier rubyid_jsonapi'>jsonapi</span> <span class='label'>resource:</span> <span class='const'>MyResource</span>
|
597
|
+
|
598
|
+
<span class='id identifier rubyid_sideload_whitelist'>sideload_whitelist</span><span class='lparen'>(</span><span class='lbrace'>{</span>
|
599
|
+
<span class='label'>index:</span> <span class='lbracket'>[</span><span class='symbol'>:blog</span><span class='rbracket'>]</span><span class='comma'>,</span>
|
600
|
+
<span class='label'>show:</span> <span class='lbracket'>[</span><span class='symbol'>:blog</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>
|
601
|
+
<span class='rbrace'>}</span><span class='rparen'>)</span>
|
602
|
+
|
603
|
+
<span class='comment'># ... code ...
|
604
|
+
</span><span class='kw'>end</span>
|
605
|
+
|
606
|
+
<span class='comment'># A request to sideload 'tags'
|
607
|
+
</span><span class='comment'>#
|
608
|
+
</span><span class='comment'># GET /posts/1?include=tags
|
609
|
+
</span><span class='comment'>#
|
610
|
+
</span><span class='comment'># ...will silently fail.
|
611
|
+
</span><span class='comment'>#
|
612
|
+
</span><span class='comment'># A request for comments and tags:
|
613
|
+
</span><span class='comment'>#
|
614
|
+
</span><span class='comment'># GET /posts/1?include=tags,comments
|
615
|
+
</span><span class='comment'>#
|
616
|
+
</span><span class='comment'># ...will only sideload comments</span></code></pre>
|
617
|
+
|
618
|
+
</div>
|
619
|
+
<p class="tag_title">Parameters:</p>
|
620
|
+
<ul class="param">
|
621
|
+
|
622
|
+
<li>
|
623
|
+
|
624
|
+
<span class='name'>whitelist</span>
|
625
|
+
|
626
|
+
|
627
|
+
<span class='type'>(<tt>Hash</tt>, <tt>Array</tt>, <tt>Symbol</tt>)</span>
|
628
|
+
|
629
|
+
|
630
|
+
|
631
|
+
</li>
|
632
|
+
|
633
|
+
</ul>
|
634
|
+
|
635
|
+
|
636
|
+
<p class="tag_title">See Also:</p>
|
637
|
+
<ul class="see">
|
638
|
+
|
639
|
+
<li><span class='object_link'><a href="Query.html#include_hash-instance_method" title="JsonapiCompliable::Query#include_hash (method)">Query#include_hash</a></span></li>
|
640
|
+
|
641
|
+
</ul>
|
642
|
+
|
643
|
+
</div><table class="source_code">
|
644
|
+
<tr>
|
645
|
+
<td>
|
646
|
+
<pre class="lines">
|
647
|
+
|
648
|
+
|
649
|
+
89
|
650
|
+
90
|
651
|
+
91</pre>
|
652
|
+
</td>
|
653
|
+
<td>
|
654
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 89</span>
|
655
|
+
|
656
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_sideload_whitelist'>sideload_whitelist</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
657
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__sideload_whitelist'>_sideload_whitelist</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_hash'>hash</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span>
|
658
|
+
<span class='kw'>end</span></pre>
|
659
|
+
</td>
|
660
|
+
</tr>
|
661
|
+
</table>
|
516
662
|
</div>
|
517
663
|
|
518
664
|
</div>
|
@@ -584,13 +730,13 @@ render jsonapi: foo, default_jsonapi_render_options</code></pre>
|
|
584
730
|
<pre class="lines">
|
585
731
|
|
586
732
|
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
733
|
+
280
|
734
|
+
281
|
735
|
+
282
|
736
|
+
283</pre>
|
591
737
|
</td>
|
592
738
|
<td>
|
593
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
739
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 280</span>
|
594
740
|
|
595
741
|
<span class='kw'>def</span> <span class='id identifier rubyid_default_jsonapi_render_options'>default_jsonapi_render_options</span>
|
596
742
|
<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_options'>options</span><span class='op'>|</span>
|
@@ -645,12 +791,12 @@ render jsonapi: foo, default_jsonapi_render_options</code></pre>
|
|
645
791
|
<pre class="lines">
|
646
792
|
|
647
793
|
|
648
|
-
|
649
|
-
|
650
|
-
|
794
|
+
161
|
795
|
+
162
|
796
|
+
163</pre>
|
651
797
|
</td>
|
652
798
|
<td>
|
653
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
799
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 161</span>
|
654
800
|
|
655
801
|
<span class='kw'>def</span> <span class='id identifier rubyid_deserialized_params'>deserialized_params</span>
|
656
802
|
<span class='ivar'>@deserialized_params</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Deserializer.html" title="JsonapiCompliable::Deserializer (class)">Deserializer</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Deserializer.html#initialize-instance_method" title="JsonapiCompliable::Deserializer#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='comma'>,</span> <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='rparen'>)</span>
|
@@ -737,17 +883,17 @@ back the transaction.</p>
|
|
737
883
|
<pre class="lines">
|
738
884
|
|
739
885
|
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
886
|
+
189
|
887
|
+
190
|
888
|
+
191
|
889
|
+
192
|
890
|
+
193
|
891
|
+
194
|
892
|
+
195
|
893
|
+
196</pre>
|
748
894
|
</td>
|
749
895
|
<td>
|
750
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
896
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 189</span>
|
751
897
|
|
752
898
|
<span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_create'>jsonapi_create</span>
|
753
899
|
<span class='id identifier rubyid__persist'>_persist</span> <span class='kw'>do</span>
|
@@ -813,12 +959,12 @@ back the transaction.</p>
|
|
813
959
|
<pre class="lines">
|
814
960
|
|
815
961
|
|
816
|
-
|
817
|
-
|
818
|
-
|
962
|
+
108
|
963
|
+
109
|
964
|
+
110</pre>
|
819
965
|
</td>
|
820
966
|
<td>
|
821
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
967
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 108</span>
|
822
968
|
|
823
969
|
<span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_resource'>jsonapi_resource</span>
|
824
970
|
<span class='ivar'>@jsonapi_resource</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__jsonapi_compliable'>_jsonapi_compliable</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
@@ -905,12 +1051,12 @@ back the transaction.</p>
|
|
905
1051
|
<pre class="lines">
|
906
1052
|
|
907
1053
|
|
908
|
-
|
909
|
-
|
910
|
-
|
1054
|
+
155
|
1055
|
+
156
|
1056
|
+
157</pre>
|
911
1057
|
</td>
|
912
1058
|
<td>
|
913
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
1059
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 155</span>
|
914
1060
|
|
915
1061
|
<span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
916
1062
|
<span class='id identifier rubyid_jsonapi_resource'>jsonapi_resource</span><span class='period'>.</span><span class='id identifier rubyid_build_scope'>build_scope</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_query'>query</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span><span class='rparen'>)</span>
|
@@ -993,17 +1139,17 @@ back the transaction.</p>
|
|
993
1139
|
<pre class="lines">
|
994
1140
|
|
995
1141
|
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1142
|
+
220
|
1143
|
+
221
|
1144
|
+
222
|
1145
|
+
223
|
1146
|
+
224
|
1147
|
+
225
|
1148
|
+
226
|
1149
|
+
227</pre>
|
1004
1150
|
</td>
|
1005
1151
|
<td>
|
1006
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
1152
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 220</span>
|
1007
1153
|
|
1008
1154
|
<span class='kw'>def</span> <span class='id identifier rubyid_jsonapi_update'>jsonapi_update</span>
|
1009
1155
|
<span class='id identifier rubyid__persist'>_persist</span> <span class='kw'>do</span>
|
@@ -1069,12 +1215,12 @@ back the transaction.</p>
|
|
1069
1215
|
<pre class="lines">
|
1070
1216
|
|
1071
1217
|
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1218
|
+
116
|
1219
|
+
117
|
1220
|
+
118</pre>
|
1075
1221
|
</td>
|
1076
1222
|
<td>
|
1077
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
1223
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 116</span>
|
1078
1224
|
|
1079
1225
|
<span class='kw'>def</span> <span class='id identifier rubyid_query'>query</span>
|
1080
1226
|
<span class='ivar'>@query</span> <span class='op'>||=</span> <span class='const'><span class='object_link'><a href="Query.html" title="JsonapiCompliable::Query (class)">Query</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Query.html#initialize-instance_method" title="JsonapiCompliable::Query#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_jsonapi_resource'>jsonapi_resource</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
|
@@ -1136,12 +1282,12 @@ resource</p>
|
|
1136
1282
|
<pre class="lines">
|
1137
1283
|
|
1138
1284
|
|
1139
|
-
|
1140
|
-
|
1141
|
-
|
1285
|
+
122
|
1286
|
+
123
|
1287
|
+
124</pre>
|
1142
1288
|
</td>
|
1143
1289
|
<td>
|
1144
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
1290
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 122</span>
|
1145
1291
|
|
1146
1292
|
<span class='kw'>def</span> <span class='id identifier rubyid_query_hash'>query_hash</span>
|
1147
1293
|
<span class='ivar'>@query_hash</span> <span class='op'>||=</span> <span class='id identifier rubyid_query'>query</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span><span class='lbracket'>[</span><span class='id identifier rubyid_jsonapi_resource'>jsonapi_resource</span><span class='period'>.</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span>
|
@@ -1283,17 +1429,17 @@ avoid this, pass <tt>scope: false</tt></p>
|
|
1283
1429
|
<pre class="lines">
|
1284
1430
|
|
1285
1431
|
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1432
|
+
260
|
1433
|
+
261
|
1434
|
+
262
|
1435
|
+
263
|
1436
|
+
264
|
1437
|
+
265
|
1438
|
+
266
|
1439
|
+
267</pre>
|
1294
1440
|
</td>
|
1295
1441
|
<td>
|
1296
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
1442
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 260</span>
|
1297
1443
|
|
1298
1444
|
<span class='kw'>def</span> <span class='id identifier rubyid_render_jsonapi'>render_jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='comma'>,</span> <span class='id identifier rubyid_opts'>opts</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
1299
1445
|
<span class='id identifier rubyid_scope'>scope</span> <span class='op'>=</span> <span class='id identifier rubyid_jsonapi_scope'>jsonapi_scope</span><span class='lparen'>(</span><span class='id identifier rubyid_scope'>scope</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_opts'>opts</span><span class='lbracket'>[</span><span class='symbol'>:scope</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='kw'>false</span> <span class='op'>||</span> <span class='id identifier rubyid_scope'>scope</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Scope.html" title="JsonapiCompliable::Scope (class)">Scope</a></span></span><span class='rparen'>)</span>
|
@@ -1306,6 +1452,187 @@ avoid this, pass <tt>scope: false</tt></p>
|
|
1306
1452
|
</td>
|
1307
1453
|
</tr>
|
1308
1454
|
</table>
|
1455
|
+
</div>
|
1456
|
+
|
1457
|
+
<div class="method_details ">
|
1458
|
+
<h3 class="signature " id="sideload_whitelist-instance_method">
|
1459
|
+
|
1460
|
+
#<strong>sideload_whitelist</strong> ⇒ <tt>Object</tt>
|
1461
|
+
|
1462
|
+
|
1463
|
+
|
1464
|
+
|
1465
|
+
|
1466
|
+
</h3><div class="docstring">
|
1467
|
+
<div class="discussion">
|
1468
|
+
<p class="note private">
|
1469
|
+
<strong>This method is part of a private API.</strong>
|
1470
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
1471
|
+
</p>
|
1472
|
+
|
1473
|
+
|
1474
|
+
</div>
|
1475
|
+
</div>
|
1476
|
+
<div class="tags">
|
1477
|
+
|
1478
|
+
|
1479
|
+
</div><table class="source_code">
|
1480
|
+
<tr>
|
1481
|
+
<td>
|
1482
|
+
<pre class="lines">
|
1483
|
+
|
1484
|
+
|
1485
|
+
21
|
1486
|
+
22
|
1487
|
+
23
|
1488
|
+
24
|
1489
|
+
25
|
1490
|
+
26
|
1491
|
+
27
|
1492
|
+
28
|
1493
|
+
29
|
1494
|
+
30
|
1495
|
+
31
|
1496
|
+
32
|
1497
|
+
33
|
1498
|
+
34
|
1499
|
+
35
|
1500
|
+
36
|
1501
|
+
37
|
1502
|
+
38
|
1503
|
+
39
|
1504
|
+
40
|
1505
|
+
41
|
1506
|
+
42
|
1507
|
+
43
|
1508
|
+
44
|
1509
|
+
45
|
1510
|
+
46
|
1511
|
+
47
|
1512
|
+
48
|
1513
|
+
49
|
1514
|
+
50
|
1515
|
+
51
|
1516
|
+
52
|
1517
|
+
53
|
1518
|
+
54
|
1519
|
+
55
|
1520
|
+
56
|
1521
|
+
57
|
1522
|
+
58
|
1523
|
+
59
|
1524
|
+
60
|
1525
|
+
61
|
1526
|
+
62
|
1527
|
+
63
|
1528
|
+
64
|
1529
|
+
65
|
1530
|
+
66
|
1531
|
+
67
|
1532
|
+
68
|
1533
|
+
69
|
1534
|
+
70
|
1535
|
+
71
|
1536
|
+
72
|
1537
|
+
73
|
1538
|
+
74
|
1539
|
+
75
|
1540
|
+
76
|
1541
|
+
77
|
1542
|
+
78
|
1543
|
+
79
|
1544
|
+
80
|
1545
|
+
81
|
1546
|
+
82
|
1547
|
+
83
|
1548
|
+
84
|
1549
|
+
85
|
1550
|
+
86
|
1551
|
+
87
|
1552
|
+
88
|
1553
|
+
89
|
1554
|
+
90
|
1555
|
+
91
|
1556
|
+
92</pre>
|
1557
|
+
</td>
|
1558
|
+
<td>
|
1559
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 21</span>
|
1560
|
+
|
1561
|
+
<span class='kw'>module</span> <span class='const'>ClassMethods</span>
|
1562
|
+
<span class='comment'># Define your JSONAPI configuration
|
1563
|
+
</span> <span class='comment'>#
|
1564
|
+
</span> <span class='comment'># @example Inline Resource
|
1565
|
+
</span> <span class='comment'># # 'Quick and Dirty' solution that does not require a separate
|
1566
|
+
</span> <span class='comment'># # Resource object
|
1567
|
+
</span> <span class='comment'># class PostsController < ApplicationController
|
1568
|
+
</span> <span class='comment'># jsonapi do
|
1569
|
+
</span> <span class='comment'># type :posts
|
1570
|
+
</span> <span class='comment'># use_adapter JsonapiCompliable::Adapters::ActiveRecord
|
1571
|
+
</span> <span class='comment'>#
|
1572
|
+
</span> <span class='comment'># allow_filter :title
|
1573
|
+
</span> <span class='comment'># end
|
1574
|
+
</span> <span class='comment'># end
|
1575
|
+
</span> <span class='comment'>#
|
1576
|
+
</span> <span class='comment'># @example Resource Class (preferred)
|
1577
|
+
</span> <span class='comment'># # Make code reusable by encapsulating it in a Resource class
|
1578
|
+
</span> <span class='comment'># class PostsController < ApplicationController
|
1579
|
+
</span> <span class='comment'># jsonapi resource: PostResource
|
1580
|
+
</span> <span class='comment'># end
|
1581
|
+
</span> <span class='comment'>#
|
1582
|
+
</span> <span class='comment'># @see Resource
|
1583
|
+
</span> <span class='comment'># @param resource [Resource] the Resource class associated to this endpoint
|
1584
|
+
</span> <span class='comment'># @return [void]
|
1585
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_jsonapi'>jsonapi</span><span class='lparen'>(</span><span class='id identifier rubyid_foo'>foo</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>bar</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='label'>resource:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span>
|
1586
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_resource'>resource</span>
|
1587
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span>
|
1588
|
+
<span class='kw'>else</span>
|
1589
|
+
<span class='kw'>if</span> <span class='op'>!</span><span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span>
|
1590
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span> <span class='op'>=</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../JsonapiCompliable.html" title="JsonapiCompliable (module)">JsonapiCompliable</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Resource.html" title="JsonapiCompliable::Resource (class)">Resource</a></span></span><span class='rparen'>)</span>
|
1591
|
+
<span class='kw'>end</span>
|
1592
|
+
<span class='kw'>end</span>
|
1593
|
+
|
1594
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__jsonapi_compliable'>_jsonapi_compliable</span><span class='period'>.</span><span class='id identifier rubyid_class_eval'>class_eval</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_blk'>blk</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_blk'>blk</span>
|
1595
|
+
<span class='kw'>end</span>
|
1596
|
+
|
1597
|
+
<span class='comment'># Set the sideload whitelist. You may want to omit sideloads for
|
1598
|
+
</span> <span class='comment'># security or performance reasons.
|
1599
|
+
</span> <span class='comment'>#
|
1600
|
+
</span> <span class='comment'># Uses JSONAPI::IncludeDirective from {{http://jsonapi-rb.org jsonapi-rb}}
|
1601
|
+
</span> <span class='comment'>#
|
1602
|
+
</span> <span class='comment'># @example Whitelisting Relationships
|
1603
|
+
</span> <span class='comment'># # Given the following whitelist
|
1604
|
+
</span> <span class='comment'># class PostsController < ApplicationResource
|
1605
|
+
</span> <span class='comment'># jsonapi resource: MyResource
|
1606
|
+
</span> <span class='comment'>#
|
1607
|
+
</span> <span class='comment'># sideload_whitelist({
|
1608
|
+
</span> <span class='comment'># index: [:blog],
|
1609
|
+
</span> <span class='comment'># show: [:blog, { comments: :author }]
|
1610
|
+
</span> <span class='comment'># })
|
1611
|
+
</span> <span class='comment'>#
|
1612
|
+
</span> <span class='comment'># # ... code ...
|
1613
|
+
</span> <span class='comment'># end
|
1614
|
+
</span> <span class='comment'>#
|
1615
|
+
</span> <span class='comment'># # A request to sideload 'tags'
|
1616
|
+
</span> <span class='comment'># #
|
1617
|
+
</span> <span class='comment'># # GET /posts/1?include=tags
|
1618
|
+
</span> <span class='comment'># #
|
1619
|
+
</span> <span class='comment'># # ...will silently fail.
|
1620
|
+
</span> <span class='comment'># #
|
1621
|
+
</span> <span class='comment'># # A request for comments and tags:
|
1622
|
+
</span> <span class='comment'># #
|
1623
|
+
</span> <span class='comment'># # GET /posts/1?include=tags,comments
|
1624
|
+
</span> <span class='comment'># #
|
1625
|
+
</span> <span class='comment'># # ...will only sideload comments
|
1626
|
+
</span> <span class='comment'>#
|
1627
|
+
</span> <span class='comment'># @param [Hash, Array, Symbol] whitelist
|
1628
|
+
</span> <span class='comment'># @see Query#include_hash
|
1629
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_sideload_whitelist'>sideload_whitelist</span><span class='lparen'>(</span><span class='id identifier rubyid_hash'>hash</span><span class='rparen'>)</span>
|
1630
|
+
<span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid__sideload_whitelist'>_sideload_whitelist</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_hash'>hash</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_hash'>to_hash</span>
|
1631
|
+
<span class='kw'>end</span>
|
1632
|
+
<span class='kw'>end</span></pre>
|
1633
|
+
</td>
|
1634
|
+
</tr>
|
1635
|
+
</table>
|
1309
1636
|
</div>
|
1310
1637
|
|
1311
1638
|
<div class="method_details ">
|
@@ -1357,14 +1684,14 @@ Helpful for easy-access to things like the current user.</p>
|
|
1357
1684
|
<pre class="lines">
|
1358
1685
|
|
1359
1686
|
|
1360
|
-
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1687
|
+
132
|
1688
|
+
133
|
1689
|
+
134
|
1690
|
+
135
|
1691
|
+
136</pre>
|
1365
1692
|
</td>
|
1366
1693
|
<td>
|
1367
|
-
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line
|
1694
|
+
<pre class="code"><span class="info file"># File 'lib/jsonapi_compliable/base.rb', line 132</span>
|
1368
1695
|
|
1369
1696
|
<span class='kw'>def</span> <span class='id identifier rubyid_wrap_context'>wrap_context</span>
|
1370
1697
|
<span class='id identifier rubyid_jsonapi_resource'>jsonapi_resource</span><span class='period'>.</span><span class='id identifier rubyid_with_context'>with_context</span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='id identifier rubyid_action_name'>action_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span> <span class='kw'>do</span>
|
@@ -1381,7 +1708,7 @@ Helpful for easy-access to things like the current user.</p>
|
|
1381
1708
|
</div>
|
1382
1709
|
|
1383
1710
|
<div id="footer">
|
1384
|
-
Generated on
|
1711
|
+
Generated on Tue Oct 3 09:22:25 2017 by
|
1385
1712
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1386
1713
|
0.9.9 (ruby-2.3.0).
|
1387
1714
|
</div>
|
@@ -892,7 +892,7 @@ create/update/destroy/disassociate. Based on the request env or the
|
|
892
892
|
</div>
|
893
893
|
|
894
894
|
<div id="footer">
|
895
|
-
Generated on
|
895
|
+
Generated on Tue Oct 3 09:22:26 2017 by
|
896
896
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
897
897
|
0.9.9 (ruby-2.3.0).
|
898
898
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Tue Oct 3 09:22:25 2017 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.9 (ruby-2.3.0).
|
120
120
|
</div>
|
@@ -256,7 +256,7 @@
|
|
256
256
|
</div>
|
257
257
|
|
258
258
|
<div id="footer">
|
259
|
-
Generated on
|
259
|
+
Generated on Tue Oct 3 09:22:25 2017 by
|
260
260
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
261
261
|
0.9.9 (ruby-2.3.0).
|
262
262
|
</div>
|
@@ -254,7 +254,7 @@
|
|
254
254
|
</div>
|
255
255
|
|
256
256
|
<div id="footer">
|
257
|
-
Generated on
|
257
|
+
Generated on Tue Oct 3 09:22:25 2017 by
|
258
258
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
259
259
|
0.9.9 (ruby-2.3.0).
|
260
260
|
</div>
|
@@ -114,7 +114,7 @@
|
|
114
114
|
</div>
|
115
115
|
|
116
116
|
<div id="footer">
|
117
|
-
Generated on
|
117
|
+
Generated on Tue Oct 3 09:22:25 2017 by
|
118
118
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
119
119
|
0.9.9 (ruby-2.3.0).
|
120
120
|
</div>
|
@@ -105,7 +105,7 @@
|
|
105
105
|
</div>
|
106
106
|
|
107
107
|
<div id="footer">
|
108
|
-
Generated on
|
108
|
+
Generated on Tue Oct 3 09:22:25 2017 by
|
109
109
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
110
110
|
0.9.9 (ruby-2.3.0).
|
111
111
|
</div>
|