ballast 2.2.4 → 2.2.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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -1
  3. data/.travis-gemfile +2 -2
  4. data/.travis.yml +5 -3
  5. data/.yardopts +1 -1
  6. data/CHANGELOG.md +9 -0
  7. data/Gemfile +1 -1
  8. data/LICENSE.md +21 -0
  9. data/README.md +22 -17
  10. data/Rakefile +1 -1
  11. data/ballast.gemspec +1 -1
  12. data/{doc → docs}/Ballast.html +19 -21
  13. data/docs/Ballast/AjaxResponse.html +1470 -0
  14. data/{doc → docs}/Ballast/Concerns.html +3 -3
  15. data/{doc → docs}/Ballast/Concerns/AjaxHandling.html +33 -38
  16. data/{doc → docs}/Ballast/Concerns/Common.html +45 -52
  17. data/{doc → docs}/Ballast/Concerns/ErrorsHandling.html +13 -14
  18. data/docs/Ballast/Concerns/JSONApi.html +127 -0
  19. data/docs/Ballast/Concerns/JSONApi/PaginationHandling.html +617 -0
  20. data/docs/Ballast/Concerns/JSONApi/RequestHandling.html +775 -0
  21. data/docs/Ballast/Concerns/JSONApi/ResponseHandling.html +917 -0
  22. data/{doc → docs}/Ballast/Concerns/View.html +35 -42
  23. data/{doc → docs}/Ballast/Configuration.html +19 -22
  24. data/{doc → docs}/Ballast/Emoji.html +1 -1
  25. data/{doc → docs}/Ballast/Emoji/Character.html +15 -18
  26. data/docs/Ballast/Emoji/Utils.html +794 -0
  27. data/{doc → docs}/Ballast/Errors.html +1 -1
  28. data/{doc → docs}/Ballast/Errors/Base.html +16 -18
  29. data/{doc → docs}/Ballast/Errors/Failure.html +1 -1
  30. data/{doc → docs}/Ballast/Errors/InvalidDomain.html +1 -1
  31. data/{doc → docs}/Ballast/Errors/ValidationFailure.html +1 -1
  32. data/{doc → docs}/Ballast/Middlewares.html +1 -1
  33. data/{doc → docs}/Ballast/Middlewares/DefaultHost.html +16 -18
  34. data/docs/Ballast/RequestDomainMatcher.html +917 -0
  35. data/docs/Ballast/Service.html +1513 -0
  36. data/docs/Ballast/Service/Response.html +1270 -0
  37. data/{doc → docs}/Ballast/Version.html +5 -9
  38. data/{doc → docs}/_index.html +45 -1
  39. data/docs/class_list.html +58 -0
  40. data/{doc → docs}/css/common.css +0 -0
  41. data/{doc → docs}/css/full_list.css +0 -0
  42. data/{doc → docs}/css/style.css +0 -0
  43. data/{doc → docs}/file.README.html +7 -5
  44. data/{doc → docs}/file_list.html +0 -0
  45. data/{doc → docs}/frames.html +0 -0
  46. data/{doc → docs}/index.html +7 -5
  47. data/{doc → docs}/js/app.js +0 -0
  48. data/{doc → docs}/js/full_list.js +0 -0
  49. data/{doc → docs}/js/jquery.js +0 -0
  50. data/{doc → docs}/method_list.html +150 -36
  51. data/docs/top-level-namespace.html +149 -0
  52. data/lib/ballast.rb +1 -1
  53. data/lib/ballast/ajax_response.rb +1 -1
  54. data/lib/ballast/concerns/ajax_handling.rb +1 -1
  55. data/lib/ballast/concerns/common.rb +1 -1
  56. data/lib/ballast/concerns/errors_handling.rb +1 -1
  57. data/lib/ballast/concerns/json_api/pagination_handling.rb +83 -0
  58. data/lib/ballast/concerns/json_api/request_handling.rb +235 -0
  59. data/lib/ballast/concerns/json_api/response_handling.rb +70 -0
  60. data/lib/ballast/concerns/view.rb +1 -1
  61. data/lib/ballast/configuration.rb +1 -1
  62. data/lib/ballast/emoji.rb +1 -1
  63. data/lib/ballast/errors.rb +1 -1
  64. data/lib/ballast/middlewares/default_host.rb +1 -1
  65. data/lib/ballast/request_domain_matcher.rb +1 -1
  66. data/lib/ballast/service.rb +1 -1
  67. data/lib/ballast/version.rb +2 -2
  68. data/spec/ballast/ajax_response_spec.rb +1 -1
  69. data/spec/ballast/concerns/ajax_handling_spec.rb +1 -1
  70. data/spec/ballast/concerns/common_spec.rb +1 -1
  71. data/spec/ballast/concerns/errors_handling_spec.rb +1 -1
  72. data/spec/ballast/concerns/view_spec.rb +1 -1
  73. data/spec/ballast/configuration_spec.rb +1 -1
  74. data/spec/ballast/errors_spec.rb +1 -1
  75. data/spec/ballast/middlewares/default_host_spec.rb +1 -1
  76. data/spec/ballast/request_domain_matcher_spec.rb +1 -1
  77. data/spec/ballast_spec.rb +1 -1
  78. data/spec/spec_helper.rb +1 -1
  79. metadata +47 -39
  80. data/doc/Ballast/AjaxResponse.html +0 -1478
  81. data/doc/Ballast/Emoji/Utils.html +0 -799
  82. data/doc/Ballast/RequestDomainMatcher.html +0 -923
  83. data/doc/Ballast/Service.html +0 -1522
  84. data/doc/Ballast/Service/Response.html +0 -1278
  85. data/doc/class_list.html +0 -58
  86. data/doc/top-level-namespace.html +0 -112
@@ -0,0 +1,775 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>
7
+ Module: Ballast::Concerns::JSONApi::RequestHandling
8
+
9
+ &mdash; Documentation by YARD 0.8.7.6
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
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../../../';
20
+ framesUrl = "../../../frames.html#!Ballast/Concerns/JSONApi/RequestHandling.html";
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../../../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../../../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../../../_index.html">Index (R)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../../../Ballast.html" title="Ballast (module)">Ballast</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../../Concerns.html" title="Ballast::Concerns (module)">Concerns</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../JSONApi.html" title="Ballast::Concerns::JSONApi (module)">JSONApi</a></span></span>
36
+ &raquo;
37
+ <span class="title">RequestHandling</span>
38
+
39
+
40
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
41
+ </div>
42
+
43
+ <div id="search">
44
+
45
+ <a class="full_list_link" id="class_list_link"
46
+ href="../../../class_list.html">
47
+ Class List
48
+ </a>
49
+
50
+ <a class="full_list_link" id="method_list_link"
51
+ href="../../../method_list.html">
52
+ Method List
53
+ </a>
54
+
55
+ <a class="full_list_link" id="file_list_link"
56
+ href="../../../file_list.html">
57
+ File List
58
+ </a>
59
+
60
+ </div>
61
+ <div class="clear"></div>
62
+ </div>
63
+
64
+ <iframe id="search_frame"></iframe>
65
+
66
+ <div id="content"><h1>Module: Ballast::Concerns::JSONApi::RequestHandling
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+ <dt class="r1 last">Defined in:</dt>
82
+ <dd class="r1 last">lib/ballast/concerns/json_api/request_handling.rb</dd>
83
+
84
+ </dl>
85
+ <div class="clear"></div>
86
+
87
+ <h2>Overview</h2><div class="docstring">
88
+ <div class="discussion">
89
+ <p>A concern to handle JSON API requests.</p>
90
+
91
+
92
+ </div>
93
+ </div>
94
+ <div class="tags">
95
+
96
+
97
+ </div>
98
+ <h2>Constant Summary</h2>
99
+
100
+ <dl class="constants">
101
+
102
+ <dt id="CONTENT_TYPE-constant" class="">CONTENT_TYPE =
103
+ <div class="docstring">
104
+ <div class="discussion">
105
+ <p>The default JSON API Content-Type.</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+ </dt>
115
+ <dd><pre class="code"><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>application/vnd.api+json</span><span class='tstring_end'>&quot;</span></span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span></pre></dd>
116
+
117
+ </dl>
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+ <h2>
128
+ Instance Method Summary
129
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
130
+ </h2>
131
+
132
+ <ul class="summary">
133
+
134
+ <li class="public ">
135
+ <span class="summary_signature">
136
+
137
+ <a href="#request_cast_attributes-instance_method" title="#request_cast_attributes (instance method)">- (Hash) <strong>request_cast_attributes</strong>(target, attributes) </a>
138
+
139
+
140
+
141
+ </span>
142
+
143
+
144
+
145
+
146
+
147
+
148
+
149
+
150
+
151
+ <span class="summary_desc"><div class='inline'><p>Casts attributes according to the target object definitions.</p>
152
+ </div></span>
153
+
154
+ </li>
155
+
156
+
157
+ <li class="public ">
158
+ <span class="summary_signature">
159
+
160
+ <a href="#request_extract_model-instance_method" title="#request_extract_model (instance method)">- (Hash) <strong>request_extract_model</strong>(target, type_field: :type, attributes_field: :attributes, relationships_field: :relationships) </a>
161
+
162
+
163
+
164
+ </span>
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+ <span class="summary_desc"><div class='inline'><p>Extract a model attributes from request data.</p>
175
+ </div></span>
176
+
177
+ </li>
178
+
179
+
180
+ <li class="public ">
181
+ <span class="summary_signature">
182
+
183
+ <a href="#request_handle_cors-instance_method" title="#request_handle_cors (instance method)">- (Object) <strong>request_handle_cors</strong> </a>
184
+
185
+
186
+
187
+ </span>
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+ <span class="summary_desc"><div class='inline'><p>Adds Cross Origin Request (CORS) headers.</p>
198
+ </div></span>
199
+
200
+ </li>
201
+
202
+
203
+ <li class="public ">
204
+ <span class="summary_signature">
205
+
206
+ <a href="#request_source_host-instance_method" title="#request_source_host (instance method)">- (String) <strong>request_source_host</strong> </a>
207
+
208
+
209
+
210
+ </span>
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+ <span class="summary_desc"><div class='inline'><p>Returns the current source host.</p>
221
+ </div></span>
222
+
223
+ </li>
224
+
225
+
226
+ <li class="public ">
227
+ <span class="summary_signature">
228
+
229
+ <a href="#request_valid_content_type-instance_method" title="#request_valid_content_type (instance method)">- (String) <strong>request_valid_content_type</strong> </a>
230
+
231
+
232
+
233
+ </span>
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'><p>Returns the valid Content-Type for JSON API requests.</p>
244
+ </div></span>
245
+
246
+ </li>
247
+
248
+
249
+ <li class="public ">
250
+ <span class="summary_signature">
251
+
252
+ <a href="#request_validate-instance_method" title="#request_validate (instance method)">- (Object) <strong>request_validate</strong> </a>
253
+
254
+
255
+
256
+ </span>
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+ <span class="summary_desc"><div class='inline'><p>Validates a request.</p>
267
+ </div></span>
268
+
269
+ </li>
270
+
271
+
272
+ </ul>
273
+
274
+
275
+
276
+
277
+ <div id="instance_method_details" class="method_details_list">
278
+ <h2>Instance Method Details</h2>
279
+
280
+
281
+ <div class="method_details first">
282
+ <h3 class="signature first" id="request_cast_attributes-instance_method">
283
+
284
+ - (<tt>Hash</tt>) <strong>request_cast_attributes</strong>(target, attributes)
285
+
286
+
287
+
288
+
289
+
290
+ </h3><div class="docstring">
291
+ <div class="discussion">
292
+ <p>Casts attributes according to the target object definitions.</p>
293
+
294
+
295
+ </div>
296
+ </div>
297
+ <div class="tags">
298
+ <p class="tag_title">Parameters:</p>
299
+ <ul class="param">
300
+
301
+ <li>
302
+
303
+ <span class='name'>target</span>
304
+
305
+
306
+ <span class='type'>(<tt>Object</tt>)</span>
307
+
308
+
309
+
310
+ &mdash;
311
+ <div class='inline'><p>The target object.</p>
312
+ </div>
313
+
314
+ </li>
315
+
316
+ <li>
317
+
318
+ <span class='name'>attributes</span>
319
+
320
+
321
+ <span class='type'>(<tt>Hash</tt>)</span>
322
+
323
+
324
+
325
+ &mdash;
326
+ <div class='inline'><p>The attributes to cast.</p>
327
+ </div>
328
+
329
+ </li>
330
+
331
+ </ul>
332
+
333
+ <p class="tag_title">Returns:</p>
334
+ <ul class="return">
335
+
336
+ <li>
337
+
338
+
339
+ <span class='type'>(<tt>Hash</tt>)</span>
340
+
341
+
342
+
343
+ &mdash;
344
+ <div class='inline'><p>The casted attributes.</p>
345
+ </div>
346
+
347
+ </li>
348
+
349
+ </ul>
350
+
351
+ </div><table class="source_code">
352
+ <tr>
353
+ <td>
354
+ <pre class="lines">
355
+
356
+
357
+ 76
358
+ 77
359
+ 78
360
+ 79
361
+ 80
362
+ 81
363
+ 82
364
+ 83
365
+ 84</pre>
366
+ </td>
367
+ <td>
368
+ <pre class="code"><span class="info file"># File 'lib/ballast/concerns/json_api/request_handling.rb', line 76</span>
369
+
370
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_cast_attributes'>request_cast_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='rparen'>)</span>
371
+ <span class='id identifier rubyid_types'>types</span> <span class='op'>=</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_column_types'>column_types</span>
372
+
373
+ <span class='id identifier rubyid_attributes'>attributes</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_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
374
+ <span class='id identifier rubyid_request_cast_attribute'>request_cast_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_attributes'>attributes</span><span class='comma'>,</span> <span class='id identifier rubyid_types'>types</span><span class='comma'>,</span> <span class='id identifier rubyid_k'>k</span><span class='comma'>,</span> <span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span>
375
+ <span class='kw'>end</span>
376
+
377
+ <span class='id identifier rubyid_attributes'>attributes</span>
378
+ <span class='kw'>end</span></pre>
379
+ </td>
380
+ </tr>
381
+ </table>
382
+ </div>
383
+
384
+ <div class="method_details ">
385
+ <h3 class="signature " id="request_extract_model-instance_method">
386
+
387
+ - (<tt>Hash</tt>) <strong>request_extract_model</strong>(target, type_field: :type, attributes_field: :attributes, relationships_field: :relationships)
388
+
389
+
390
+
391
+
392
+
393
+ </h3><div class="docstring">
394
+ <div class="discussion">
395
+ <p>Extract a model attributes from request data</p>
396
+
397
+
398
+ </div>
399
+ </div>
400
+ <div class="tags">
401
+ <p class="tag_title">Parameters:</p>
402
+ <ul class="param">
403
+
404
+ <li>
405
+
406
+ <span class='name'>target</span>
407
+
408
+
409
+ <span class='type'>(<tt>Object</tt>)</span>
410
+
411
+
412
+
413
+ &mdash;
414
+ <div class='inline'><p>The target object.</p>
415
+ </div>
416
+
417
+ </li>
418
+
419
+ <li>
420
+
421
+ <span class='name'>type_field</span>
422
+
423
+
424
+ <span class='type'>(<tt>Symbol</tt>)</span>
425
+
426
+
427
+
428
+ &mdash;
429
+ <div class='inline'><p>The field of the request data which contains the data type.</p>
430
+ </div>
431
+
432
+ </li>
433
+
434
+ <li>
435
+
436
+ <span class='name'>attributes_field</span>
437
+
438
+
439
+ <span class='type'>(<tt>Object</tt>)</span>
440
+
441
+
442
+
443
+ &mdash;
444
+ <div class='inline'><p>The field of the request data which contains the data attributes.</p>
445
+ </div>
446
+
447
+ </li>
448
+
449
+ <li>
450
+
451
+ <span class='name'>relationships_field</span>
452
+
453
+
454
+ <span class='type'>(<tt>Object</tt>)</span>
455
+
456
+
457
+
458
+ &mdash;
459
+ <div class='inline'><p>The field of the request data which contains the data relationships.</p>
460
+ </div>
461
+
462
+ </li>
463
+
464
+ </ul>
465
+
466
+ <p class="tag_title">Returns:</p>
467
+ <ul class="return">
468
+
469
+ <li>
470
+
471
+
472
+ <span class='type'>(<tt>Hash</tt>)</span>
473
+
474
+
475
+
476
+ &mdash;
477
+ <div class='inline'><p>The model attributes.</p>
478
+ </div>
479
+
480
+ </li>
481
+
482
+ </ul>
483
+
484
+ </div><table class="source_code">
485
+ <tr>
486
+ <td>
487
+ <pre class="lines">
488
+
489
+
490
+ 54
491
+ 55
492
+ 56
493
+ 57
494
+ 58
495
+ 59
496
+ 60
497
+ 61
498
+ 62
499
+ 63
500
+ 64
501
+ 65
502
+ 66
503
+ 67
504
+ 68
505
+ 69</pre>
506
+ </td>
507
+ <td>
508
+ <pre class="code"><span class="info file"># File 'lib/ballast/concerns/json_api/request_handling.rb', line 54</span>
509
+
510
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_extract_model'>request_extract_model</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='label'>type_field:</span> <span class='symbol'>:type</span><span class='comma'>,</span> <span class='label'>attributes_field:</span> <span class='symbol'>:attributes</span><span class='comma'>,</span> <span class='label'>relationships_field:</span> <span class='symbol'>:relationships</span><span class='rparen'>)</span>
511
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span>
512
+
513
+ <span class='id identifier rubyid_request_validate_model_type'>request_validate_model_type</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_type_field'>type_field</span><span class='rparen'>)</span>
514
+
515
+ <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span><span class='lbracket'>[</span><span class='id identifier rubyid_attributes_field'>attributes_field</span><span class='rbracket'>]</span>
516
+ <span class='id identifier rubyid_fail_request!'>fail_request!</span><span class='lparen'>(</span><span class='symbol'>:bad_request</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Missing attributes in the \&quot;attributes\&quot; field.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
517
+
518
+ <span class='comment'># Extract attributes using strong parameters
519
+ </span> <span class='id identifier rubyid_data'>data</span> <span class='op'>=</span> <span class='id identifier rubyid_unembed_relationships'>unembed_relationships</span><span class='lparen'>(</span><span class='id identifier rubyid_validate_attributes'>validate_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_data'>data</span><span class='comma'>,</span> <span class='id identifier rubyid_target'>target</span><span class='rparen'>)</span><span class='comma'>,</span> <span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_relationships_field'>relationships_field</span><span class='rparen'>)</span>
520
+
521
+ <span class='comment'># Extract relationships
522
+ </span> <span class='id identifier rubyid_data'>data</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_validate_relationships'>validate_relationships</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span><span class='comma'>,</span> <span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_relationships_field'>relationships_field</span><span class='rparen'>)</span><span class='rparen'>)</span>
523
+
524
+ <span class='id identifier rubyid_data'>data</span>
525
+ <span class='kw'>end</span></pre>
526
+ </td>
527
+ </tr>
528
+ </table>
529
+ </div>
530
+
531
+ <div class="method_details ">
532
+ <h3 class="signature " id="request_handle_cors-instance_method">
533
+
534
+ - (<tt>Object</tt>) <strong>request_handle_cors</strong>
535
+
536
+
537
+
538
+
539
+
540
+ </h3><div class="docstring">
541
+ <div class="discussion">
542
+ <p>Adds Cross Origin Request (CORS) headers.</p>
543
+
544
+
545
+ </div>
546
+ </div>
547
+ <div class="tags">
548
+
549
+
550
+ </div><table class="source_code">
551
+ <tr>
552
+ <td>
553
+ <pre class="lines">
554
+
555
+
556
+ 11
557
+ 12
558
+ 13
559
+ 14
560
+ 15
561
+ 16</pre>
562
+ </td>
563
+ <td>
564
+ <pre class="code"><span class="info file"># File 'lib/ballast/concerns/json_api/request_handling.rb', line 11</span>
565
+
566
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_handle_cors'>request_handle_cors</span>
567
+ <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Origin</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_development?'>development?</span> <span class='op'>?</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>http://</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_request_source_host'>request_source_host</span><span class='embexpr_end'>}</span><span class='tstring_content'>:4200</span><span class='tstring_end'>&quot;</span></span> <span class='op'>:</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_application'>application</span><span class='period'>.</span><span class='id identifier rubyid_secrets'>secrets</span><span class='period'>.</span><span class='id identifier rubyid_cors_source'>cors_source</span>
568
+ <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Methods</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>POST, GET, PUT, DELETE, OPTIONS</span><span class='tstring_end'>&quot;</span></span>
569
+ <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Allow-Headers</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Content-Type, X-User-Email, X-User-Token</span><span class='tstring_end'>&quot;</span></span>
570
+ <span class='id identifier rubyid_headers'>headers</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Access-Control-Max-Age</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='int'>1</span><span class='period'>.</span><span class='id identifier rubyid_year'>year</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
571
+ <span class='kw'>end</span></pre>
572
+ </td>
573
+ </tr>
574
+ </table>
575
+ </div>
576
+
577
+ <div class="method_details ">
578
+ <h3 class="signature " id="request_source_host-instance_method">
579
+
580
+ - (<tt>String</tt>) <strong>request_source_host</strong>
581
+
582
+
583
+
584
+
585
+
586
+ </h3><div class="docstring">
587
+ <div class="discussion">
588
+ <p>Returns the current source host.</p>
589
+
590
+
591
+ </div>
592
+ </div>
593
+ <div class="tags">
594
+
595
+ <p class="tag_title">Returns:</p>
596
+ <ul class="return">
597
+
598
+ <li>
599
+
600
+
601
+ <span class='type'>(<tt>String</tt>)</span>
602
+
603
+
604
+
605
+ &mdash;
606
+ <div class='inline'><p>The current source host.</p>
607
+ </div>
608
+
609
+ </li>
610
+
611
+ </ul>
612
+
613
+ </div><table class="source_code">
614
+ <tr>
615
+ <td>
616
+ <pre class="lines">
617
+
618
+
619
+ 36
620
+ 37
621
+ 38</pre>
622
+ </td>
623
+ <td>
624
+ <pre class="code"><span class="info file"># File 'lib/ballast/concerns/json_api/request_handling.rb', line 36</span>
625
+
626
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_source_host'>request_source_host</span>
627
+ <span class='ivar'>@api_source</span> <span class='op'>||=</span> <span class='const'>URI</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_url'>url</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_host'>host</span>
628
+ <span class='kw'>end</span></pre>
629
+ </td>
630
+ </tr>
631
+ </table>
632
+ </div>
633
+
634
+ <div class="method_details ">
635
+ <h3 class="signature " id="request_valid_content_type-instance_method">
636
+
637
+ - (<tt>String</tt>) <strong>request_valid_content_type</strong>
638
+
639
+
640
+
641
+
642
+
643
+ </h3><div class="docstring">
644
+ <div class="discussion">
645
+ <p>Returns the valid Content-Type for JSON API requests.</p>
646
+
647
+
648
+ </div>
649
+ </div>
650
+ <div class="tags">
651
+
652
+ <p class="tag_title">Returns:</p>
653
+ <ul class="return">
654
+
655
+ <li>
656
+
657
+
658
+ <span class='type'>(<tt>String</tt>)</span>
659
+
660
+
661
+
662
+ &mdash;
663
+ <div class='inline'><p>The valid Content-Type for JSON API requests.</p>
664
+ </div>
665
+
666
+ </li>
667
+
668
+ </ul>
669
+
670
+ </div><table class="source_code">
671
+ <tr>
672
+ <td>
673
+ <pre class="lines">
674
+
675
+
676
+ 43
677
+ 44
678
+ 45</pre>
679
+ </td>
680
+ <td>
681
+ <pre class="code"><span class="info file"># File 'lib/ballast/concerns/json_api/request_handling.rb', line 43</span>
682
+
683
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_valid_content_type'>request_valid_content_type</span>
684
+ <span class='const'>Ballast</span><span class='op'>::</span><span class='const'>Concerns</span><span class='op'>::</span><span class='const'>JSONApi</span><span class='op'>::</span><span class='const'>RequestHandling</span><span class='op'>::</span><span class='const'>CONTENT_TYPE</span>
685
+ <span class='kw'>end</span></pre>
686
+ </td>
687
+ </tr>
688
+ </table>
689
+ </div>
690
+
691
+ <div class="method_details ">
692
+ <h3 class="signature " id="request_validate-instance_method">
693
+
694
+ - (<tt>Object</tt>) <strong>request_validate</strong>
695
+
696
+
697
+
698
+
699
+
700
+ </h3><div class="docstring">
701
+ <div class="discussion">
702
+ <p>Validates a request.</p>
703
+
704
+
705
+ </div>
706
+ </div>
707
+ <div class="tags">
708
+
709
+ <p class="tag_title">Returns:</p>
710
+ <ul class="return">
711
+
712
+ <li>
713
+
714
+
715
+ <span class='type'>(<tt>Object</tt>)</span>
716
+
717
+
718
+
719
+ &mdash;
720
+ <div class='inline'><p>The request data</p>
721
+ </div>
722
+
723
+ </li>
724
+
725
+ </ul>
726
+
727
+ </div><table class="source_code">
728
+ <tr>
729
+ <td>
730
+ <pre class="lines">
731
+
732
+
733
+ 21
734
+ 22
735
+ 23
736
+ 24
737
+ 25
738
+ 26
739
+ 27
740
+ 28
741
+ 29
742
+ 30
743
+ 31</pre>
744
+ </td>
745
+ <td>
746
+ <pre class="code"><span class="info file"># File 'lib/ballast/concerns/json_api/request_handling.rb', line 21</span>
747
+
748
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_validate'>request_validate</span>
749
+ <span class='id identifier rubyid_content_type'>content_type</span> <span class='op'>=</span> <span class='id identifier rubyid_request_valid_content_type'>request_valid_content_type</span>
750
+ <span class='id identifier rubyid_request'>request</span><span class='period'>.</span><span class='id identifier rubyid_format'>format</span> <span class='op'>=</span> <span class='symbol'>:json</span>
751
+ <span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_content_type'>content_type</span> <span class='op'>=</span> <span class='id identifier rubyid_content_type'>content_type</span> <span class='kw'>unless</span> <span class='const'>Rails</span><span class='period'>.</span><span class='id identifier rubyid_env'>env</span><span class='period'>.</span><span class='id identifier rubyid_development?'>development?</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>json</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span>
752
+
753
+ <span class='ivar'>@cursor</span> <span class='op'>=</span> <span class='const'>PaginationCursor</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='comma'>,</span> <span class='symbol'>:page</span><span class='rparen'>)</span>
754
+
755
+ <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='symbol'>:data</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='const'>HashWithIndifferentAccess</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
756
+
757
+ <span class='id identifier rubyid_validate_data'>validate_data</span><span class='lparen'>(</span><span class='id identifier rubyid_content_type'>content_type</span><span class='rparen'>)</span>
758
+ <span class='kw'>end</span></pre>
759
+ </td>
760
+ </tr>
761
+ </table>
762
+ </div>
763
+
764
+ </div>
765
+
766
+ </div>
767
+
768
+ <div id="footer">
769
+ Generated on Thu Aug 18 15:49:49 2016 by
770
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
771
+ 0.8.7.6 (ruby-2.3.0).
772
+ </div>
773
+
774
+ </body>
775
+ </html>