apes 1.0.0

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 (122) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +7 -0
  3. data/.rubocop.yml +82 -0
  4. data/.travis-gemfile +15 -0
  5. data/.travis.yml +15 -0
  6. data/.yardopts +1 -0
  7. data/CHANGELOG.md +3 -0
  8. data/Gemfile +22 -0
  9. data/README.md +177 -0
  10. data/Rakefile +44 -0
  11. data/apes.gemspec +34 -0
  12. data/doc/Apes.html +130 -0
  13. data/doc/Apes/Concerns.html +127 -0
  14. data/doc/Apes/Concerns/Errors.html +1089 -0
  15. data/doc/Apes/Concerns/Pagination.html +636 -0
  16. data/doc/Apes/Concerns/Request.html +766 -0
  17. data/doc/Apes/Concerns/Response.html +940 -0
  18. data/doc/Apes/Controller.html +1100 -0
  19. data/doc/Apes/Errors.html +125 -0
  20. data/doc/Apes/Errors/AuthenticationError.html +133 -0
  21. data/doc/Apes/Errors/BadRequestError.html +157 -0
  22. data/doc/Apes/Errors/BaseError.html +320 -0
  23. data/doc/Apes/Errors/InvalidDataError.html +157 -0
  24. data/doc/Apes/Errors/MissingDataError.html +157 -0
  25. data/doc/Apes/Model.html +378 -0
  26. data/doc/Apes/PaginationCursor.html +2138 -0
  27. data/doc/Apes/RuntimeConfiguration.html +909 -0
  28. data/doc/Apes/Serializers.html +125 -0
  29. data/doc/Apes/Serializers/JSON.html +389 -0
  30. data/doc/Apes/Serializers/JWT.html +452 -0
  31. data/doc/Apes/Serializers/List.html +347 -0
  32. data/doc/Apes/UrlsParser.html +1432 -0
  33. data/doc/Apes/Validators.html +125 -0
  34. data/doc/Apes/Validators/BaseValidator.html +278 -0
  35. data/doc/Apes/Validators/BooleanValidator.html +494 -0
  36. data/doc/Apes/Validators/EmailValidator.html +350 -0
  37. data/doc/Apes/Validators/PhoneValidator.html +375 -0
  38. data/doc/Apes/Validators/ReferenceValidator.html +372 -0
  39. data/doc/Apes/Validators/TimestampValidator.html +640 -0
  40. data/doc/Apes/Validators/UuidValidator.html +372 -0
  41. data/doc/Apes/Validators/ZipCodeValidator.html +372 -0
  42. data/doc/Apes/Version.html +189 -0
  43. data/doc/ApplicationController.html +547 -0
  44. data/doc/Concerns.html +128 -0
  45. data/doc/Concerns/ErrorHandling.html +826 -0
  46. data/doc/Concerns/PaginationHandling.html +463 -0
  47. data/doc/Concerns/RequestHandling.html +512 -0
  48. data/doc/Concerns/ResponseHandling.html +579 -0
  49. data/doc/Errors.html +126 -0
  50. data/doc/Errors/AuthenticationError.html +123 -0
  51. data/doc/Errors/BadRequestError.html +147 -0
  52. data/doc/Errors/BaseError.html +289 -0
  53. data/doc/Errors/InvalidDataError.html +147 -0
  54. data/doc/Errors/MissingDataError.html +147 -0
  55. data/doc/Model.html +315 -0
  56. data/doc/PaginationCursor.html +764 -0
  57. data/doc/Serializers.html +126 -0
  58. data/doc/Serializers/JSON.html +253 -0
  59. data/doc/Serializers/JWT.html +253 -0
  60. data/doc/Serializers/List.html +245 -0
  61. data/doc/Validators.html +126 -0
  62. data/doc/Validators/BaseValidator.html +209 -0
  63. data/doc/Validators/BooleanValidator.html +391 -0
  64. data/doc/Validators/EmailValidator.html +298 -0
  65. data/doc/Validators/PhoneValidator.html +313 -0
  66. data/doc/Validators/ReferenceValidator.html +284 -0
  67. data/doc/Validators/TimestampValidator.html +476 -0
  68. data/doc/Validators/UuidValidator.html +310 -0
  69. data/doc/Validators/ZipCodeValidator.html +310 -0
  70. data/doc/_index.html +435 -0
  71. data/doc/class_list.html +58 -0
  72. data/doc/css/common.css +1 -0
  73. data/doc/css/full_list.css +57 -0
  74. data/doc/css/style.css +339 -0
  75. data/doc/file.README.html +252 -0
  76. data/doc/file_list.html +60 -0
  77. data/doc/frames.html +26 -0
  78. data/doc/index.html +252 -0
  79. data/doc/js/app.js +219 -0
  80. data/doc/js/full_list.js +181 -0
  81. data/doc/js/jquery.js +4 -0
  82. data/doc/method_list.html +615 -0
  83. data/doc/top-level-namespace.html +112 -0
  84. data/lib/apes.rb +40 -0
  85. data/lib/apes/concerns/errors.rb +111 -0
  86. data/lib/apes/concerns/pagination.rb +81 -0
  87. data/lib/apes/concerns/request.rb +237 -0
  88. data/lib/apes/concerns/response.rb +74 -0
  89. data/lib/apes/controller.rb +77 -0
  90. data/lib/apes/errors.rb +38 -0
  91. data/lib/apes/model.rb +94 -0
  92. data/lib/apes/pagination_cursor.rb +152 -0
  93. data/lib/apes/runtime_configuration.rb +80 -0
  94. data/lib/apes/serializers.rb +88 -0
  95. data/lib/apes/urls_parser.rb +233 -0
  96. data/lib/apes/validators.rb +234 -0
  97. data/lib/apes/version.rb +24 -0
  98. data/spec/apes/concerns/errors_spec.rb +141 -0
  99. data/spec/apes/concerns/pagination_spec.rb +114 -0
  100. data/spec/apes/concerns/request_spec.rb +244 -0
  101. data/spec/apes/concerns/response_spec.rb +79 -0
  102. data/spec/apes/controller_spec.rb +54 -0
  103. data/spec/apes/errors_spec.rb +14 -0
  104. data/spec/apes/models_spec.rb +148 -0
  105. data/spec/apes/pagination_cursor_spec.rb +113 -0
  106. data/spec/apes/runtime_configuration_spec.rb +100 -0
  107. data/spec/apes/serializers_spec.rb +70 -0
  108. data/spec/apes/urls_parser_spec.rb +150 -0
  109. data/spec/apes/validators_spec.rb +237 -0
  110. data/spec/spec_helper.rb +30 -0
  111. data/views/_included.json.jbuilder +9 -0
  112. data/views/_pagination.json.jbuilder +9 -0
  113. data/views/collection.json.jbuilder +4 -0
  114. data/views/errors/400.json.jbuilder +9 -0
  115. data/views/errors/403.json.jbuilder +7 -0
  116. data/views/errors/404.json.jbuilder +6 -0
  117. data/views/errors/422.json.jbuilder +19 -0
  118. data/views/errors/500.json.jbuilder +12 -0
  119. data/views/errors/501.json.jbuilder +7 -0
  120. data/views/layouts/general.json.jbuilder +36 -0
  121. data/views/object.json.jbuilder +4 -0
  122. metadata +262 -0
@@ -0,0 +1,766 @@
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: Apes::Concerns::Request
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#!Apes/Concerns/Request.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="../../Apes.html" title="Apes (module)">Apes</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Concerns.html" title="Apes::Concerns (module)">Concerns</a></span></span>
36
+ &raquo;
37
+ <span class="title">Request</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: Apes::Concerns::Request
67
+
68
+
69
+
70
+ </h1>
71
+
72
+ <dl class="box">
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+ <dt class="r1">Included in:</dt>
81
+ <dd class="r1"><span class='object_link'><a href="../Controller.html" title="Apes::Controller (class)">Apes::Controller</a></span></dd>
82
+
83
+
84
+
85
+ <dt class="r2 last">Defined in:</dt>
86
+ <dd class="r2 last">lib/apes/concerns/request.rb</dd>
87
+
88
+ </dl>
89
+ <div class="clear"></div>
90
+
91
+ <h2>Overview</h2><div class="docstring">
92
+ <div class="discussion">
93
+ <p>JSON API request handling module.</p>
94
+
95
+
96
+ </div>
97
+ </div>
98
+ <div class="tags">
99
+
100
+
101
+ </div>
102
+ <h2>Constant Summary</h2>
103
+
104
+ <dl class="constants">
105
+
106
+ <dt id="CONTENT_TYPE-constant" class="">CONTENT_TYPE =
107
+ <div class="docstring">
108
+ <div class="discussion">
109
+ <p>Valid JSON API content type</p>
110
+
111
+
112
+ </div>
113
+ </div>
114
+ <div class="tags">
115
+
116
+
117
+ </div>
118
+ </dt>
119
+ <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>
120
+
121
+ </dl>
122
+
123
+
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+ <h2>
132
+ Instance Method Summary
133
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
134
+ </h2>
135
+
136
+ <ul class="summary">
137
+
138
+ <li class="public ">
139
+ <span class="summary_signature">
140
+
141
+ <a href="#request_cast_attributes-instance_method" title="#request_cast_attributes (instance method)">- (HashWithIndifferentAccess) <strong>request_cast_attributes</strong>(target, attributes) </a>
142
+
143
+
144
+
145
+ </span>
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+ <span class="summary_desc"><div class='inline'><p>Converts attributes for a target model in the desired types.</p>
156
+ </div></span>
157
+
158
+ </li>
159
+
160
+
161
+ <li class="public ">
162
+ <span class="summary_signature">
163
+
164
+ <a href="#request_extract_model-instance_method" title="#request_extract_model (instance method)">- (HashWithIndifferentAccess) <strong>request_extract_model</strong>(target, type_field: :type, attributes_field: :attributes, relationships_field: :relationships) </a>
165
+
166
+
167
+
168
+ </span>
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+ <span class="summary_desc"><div class='inline'><p>Extract all attributes from input data making they are all valid and present.</p>
179
+ </div></span>
180
+
181
+ </li>
182
+
183
+
184
+ <li class="public ">
185
+ <span class="summary_signature">
186
+
187
+ <a href="#request_handle_cors-instance_method" title="#request_handle_cors (instance method)">- (Object) <strong>request_handle_cors</strong> </a>
188
+
189
+
190
+
191
+ </span>
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+ <span class="summary_desc"><div class='inline'><p>Sets headers for CORS handling.</p>
202
+ </div></span>
203
+
204
+ </li>
205
+
206
+
207
+ <li class="public ">
208
+ <span class="summary_signature">
209
+
210
+ <a href="#request_source_host-instance_method" title="#request_source_host (instance method)">- (Object) <strong>request_source_host</strong> </a>
211
+
212
+
213
+
214
+ </span>
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+ <span class="summary_desc"><div class='inline'><p>Returns the hostname of the client.</p>
225
+ </div></span>
226
+
227
+ </li>
228
+
229
+
230
+ <li class="public ">
231
+ <span class="summary_signature">
232
+
233
+ <a href="#request_valid_content_type-instance_method" title="#request_valid_content_type (instance method)">- (String) <strong>request_valid_content_type</strong> </a>
234
+
235
+
236
+
237
+ </span>
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+ <span class="summary_desc"><div class='inline'><p>Returns the valid content type for a non GET JSON API request.</p>
248
+ </div></span>
249
+
250
+ </li>
251
+
252
+
253
+ <li class="public ">
254
+ <span class="summary_signature">
255
+
256
+ <a href="#request_validate-instance_method" title="#request_validate (instance method)">- (Object) <strong>request_validate</strong> </a>
257
+
258
+
259
+
260
+ </span>
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+ <span class="summary_desc"><div class='inline'><p>Validates a request according to JSON API.</p>
271
+ </div></span>
272
+
273
+ </li>
274
+
275
+
276
+ </ul>
277
+
278
+
279
+
280
+
281
+ <div id="instance_method_details" class="method_details_list">
282
+ <h2>Instance Method Details</h2>
283
+
284
+
285
+ <div class="method_details first">
286
+ <h3 class="signature first" id="request_cast_attributes-instance_method">
287
+
288
+ - (<tt>HashWithIndifferentAccess</tt>) <strong>request_cast_attributes</strong>(target, attributes)
289
+
290
+
291
+
292
+
293
+
294
+ </h3><div class="docstring">
295
+ <div class="discussion">
296
+ <p>Converts attributes for a target model in the desired types.</p>
297
+
298
+
299
+ </div>
300
+ </div>
301
+ <div class="tags">
302
+ <p class="tag_title">Parameters:</p>
303
+ <ul class="param">
304
+
305
+ <li>
306
+
307
+ <span class='name'>target</span>
308
+
309
+
310
+ <span class='type'>(<tt>Object</tt>)</span>
311
+
312
+
313
+
314
+ &mdash;
315
+ <div class='inline'><p>The target model. This is use to obtain types.</p>
316
+ </div>
317
+
318
+ </li>
319
+
320
+ <li>
321
+
322
+ <span class='name'>attributes</span>
323
+
324
+
325
+ <span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
326
+
327
+
328
+
329
+ &mdash;
330
+ <div class='inline'><p>The attributes to convert.</p>
331
+ </div>
332
+
333
+ </li>
334
+
335
+ </ul>
336
+
337
+ <p class="tag_title">Returns:</p>
338
+ <ul class="return">
339
+
340
+ <li>
341
+
342
+
343
+ <span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
344
+
345
+
346
+
347
+ &mdash;
348
+ <div class='inline'><p>The converted attributes.</p>
349
+ </div>
350
+
351
+ </li>
352
+
353
+ </ul>
354
+
355
+ </div><table class="source_code">
356
+ <tr>
357
+ <td>
358
+ <pre class="lines">
359
+
360
+
361
+ 79
362
+ 80
363
+ 81
364
+ 82
365
+ 83
366
+ 84
367
+ 85
368
+ 86
369
+ 87</pre>
370
+ </td>
371
+ <td>
372
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 79</span>
373
+
374
+ <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>
375
+ <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>
376
+
377
+ <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>
378
+ <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>
379
+ <span class='kw'>end</span>
380
+
381
+ <span class='id identifier rubyid_attributes'>attributes</span>
382
+ <span class='kw'>end</span></pre>
383
+ </td>
384
+ </tr>
385
+ </table>
386
+ </div>
387
+
388
+ <div class="method_details ">
389
+ <h3 class="signature " id="request_extract_model-instance_method">
390
+
391
+ - (<tt>HashWithIndifferentAccess</tt>) <strong>request_extract_model</strong>(target, type_field: :type, attributes_field: :attributes, relationships_field: :relationships)
392
+
393
+
394
+
395
+
396
+
397
+ </h3><div class="docstring">
398
+ <div class="discussion">
399
+ <p>Extract all attributes from input data making they are all valid and present.</p>
400
+
401
+
402
+ </div>
403
+ </div>
404
+ <div class="tags">
405
+ <p class="tag_title">Parameters:</p>
406
+ <ul class="param">
407
+
408
+ <li>
409
+
410
+ <span class='name'>target</span>
411
+
412
+
413
+ <span class='type'>(<tt>Object</tt>)</span>
414
+
415
+
416
+
417
+ &mdash;
418
+ <div class='inline'><p>The target model. This is use to obtain validations.</p>
419
+ </div>
420
+
421
+ </li>
422
+
423
+ <li>
424
+
425
+ <span class='name'>type_field</span>
426
+
427
+
428
+ <span class='type'>(<tt>Symbol</tt>)</span>
429
+
430
+
431
+
432
+ &mdash;
433
+ <div class='inline'><p>The attribute which contains input type.</p>
434
+ </div>
435
+
436
+ </li>
437
+
438
+ <li>
439
+
440
+ <span class='name'>attributes_field</span>
441
+
442
+
443
+ <span class='type'>(<tt>Symbol</tt>)</span>
444
+
445
+
446
+
447
+ &mdash;
448
+ <div class='inline'><p>The attribute which contains input attributes.</p>
449
+ </div>
450
+
451
+ </li>
452
+
453
+ <li>
454
+
455
+ <span class='name'>relationships_field</span>
456
+
457
+
458
+ <span class='type'>(<tt>Symbol</tt>)</span>
459
+
460
+
461
+
462
+ &mdash;
463
+ <div class='inline'><p>The attribute which contains relationships specifications.</p>
464
+ </div>
465
+
466
+ </li>
467
+
468
+ </ul>
469
+
470
+ <p class="tag_title">Returns:</p>
471
+ <ul class="return">
472
+
473
+ <li>
474
+
475
+
476
+ <span class='type'>(<tt>HashWithIndifferentAccess</tt>)</span>
477
+
478
+
479
+
480
+ &mdash;
481
+ <div class='inline'><p>The attributes to create or update a target model.</p>
482
+ </div>
483
+
484
+ </li>
485
+
486
+ </ul>
487
+
488
+ </div><table class="source_code">
489
+ <tr>
490
+ <td>
491
+ <pre class="lines">
492
+
493
+
494
+ 57
495
+ 58
496
+ 59
497
+ 60
498
+ 61
499
+ 62
500
+ 63
501
+ 64
502
+ 65
503
+ 66
504
+ 67
505
+ 68
506
+ 69
507
+ 70
508
+ 71
509
+ 72</pre>
510
+ </td>
511
+ <td>
512
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 57</span>
513
+
514
+ <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>
515
+ <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>
516
+
517
+ <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>
518
+
519
+ <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>
520
+ <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>
521
+
522
+ <span class='comment'># Extract attributes using strong parameters
523
+ </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>
524
+
525
+ <span class='comment'># Extract relationships
526
+ </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>
527
+
528
+ <span class='id identifier rubyid_data'>data</span>
529
+ <span class='kw'>end</span></pre>
530
+ </td>
531
+ </tr>
532
+ </table>
533
+ </div>
534
+
535
+ <div class="method_details ">
536
+ <h3 class="signature " id="request_handle_cors-instance_method">
537
+
538
+ - (<tt>Object</tt>) <strong>request_handle_cors</strong>
539
+
540
+
541
+
542
+
543
+
544
+ </h3><div class="docstring">
545
+ <div class="discussion">
546
+ <p>Sets headers for CORS handling.</p>
547
+
548
+
549
+ </div>
550
+ </div>
551
+ <div class="tags">
552
+
553
+
554
+ </div><table class="source_code">
555
+ <tr>
556
+ <td>
557
+ <pre class="lines">
558
+
559
+
560
+ 14
561
+ 15
562
+ 16
563
+ 17
564
+ 18
565
+ 19
566
+ 20
567
+ 21</pre>
568
+ </td>
569
+ <td>
570
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 14</span>
571
+
572
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_handle_cors'>request_handle_cors</span>
573
+ <span class='id identifier rubyid_cors_source'>cors_source</span> <span class='op'>=</span> <span class='const'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</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'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</span><span class='period'>.</span><span class='id identifier rubyid_cors_source'>cors_source</span>
574
+
575
+ <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='id identifier rubyid_cors_source'>cors_source</span>
576
+ <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>
577
+ <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>
578
+ <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>
579
+ <span class='kw'>end</span></pre>
580
+ </td>
581
+ </tr>
582
+ </table>
583
+ </div>
584
+
585
+ <div class="method_details ">
586
+ <h3 class="signature " id="request_source_host-instance_method">
587
+
588
+ - (<tt>Object</tt>) <strong>request_source_host</strong>
589
+
590
+
591
+
592
+
593
+
594
+ </h3><div class="docstring">
595
+ <div class="discussion">
596
+ <p>Returns the hostname of the client.</p>
597
+
598
+
599
+ </div>
600
+ </div>
601
+ <div class="tags">
602
+
603
+ <p class="tag_title">Returns:</p>
604
+ <ul class="return">
605
+
606
+ <li>
607
+
608
+
609
+ <span class='type'></span>
610
+
611
+
612
+
613
+
614
+ <div class='inline'><p>The hostname of the client.</p>
615
+ </div>
616
+
617
+ </li>
618
+
619
+ </ul>
620
+
621
+ </div><table class="source_code">
622
+ <tr>
623
+ <td>
624
+ <pre class="lines">
625
+
626
+
627
+ 39
628
+ 40
629
+ 41</pre>
630
+ </td>
631
+ <td>
632
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 39</span>
633
+
634
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_source_host'>request_source_host</span>
635
+ <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>
636
+ <span class='kw'>end</span></pre>
637
+ </td>
638
+ </tr>
639
+ </table>
640
+ </div>
641
+
642
+ <div class="method_details ">
643
+ <h3 class="signature " id="request_valid_content_type-instance_method">
644
+
645
+ - (<tt>String</tt>) <strong>request_valid_content_type</strong>
646
+
647
+
648
+
649
+
650
+
651
+ </h3><div class="docstring">
652
+ <div class="discussion">
653
+ <p>Returns the valid content type for a non GET JSON API request.</p>
654
+
655
+
656
+ </div>
657
+ </div>
658
+ <div class="tags">
659
+
660
+ <p class="tag_title">Returns:</p>
661
+ <ul class="return">
662
+
663
+ <li>
664
+
665
+
666
+ <span class='type'>(<tt>String</tt>)</span>
667
+
668
+
669
+
670
+ &mdash;
671
+ <div class='inline'><p>valid content type for a JSON API request.</p>
672
+ </div>
673
+
674
+ </li>
675
+
676
+ </ul>
677
+
678
+ </div><table class="source_code">
679
+ <tr>
680
+ <td>
681
+ <pre class="lines">
682
+
683
+
684
+ 46
685
+ 47
686
+ 48</pre>
687
+ </td>
688
+ <td>
689
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 46</span>
690
+
691
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_valid_content_type'>request_valid_content_type</span>
692
+ <span class='const'>Apes</span><span class='op'>::</span><span class='const'>Concerns</span><span class='op'>::</span><span class='const'>Request</span><span class='op'>::</span><span class='const'>CONTENT_TYPE</span>
693
+ <span class='kw'>end</span></pre>
694
+ </td>
695
+ </tr>
696
+ </table>
697
+ </div>
698
+
699
+ <div class="method_details ">
700
+ <h3 class="signature " id="request_validate-instance_method">
701
+
702
+ - (<tt>Object</tt>) <strong>request_validate</strong>
703
+
704
+
705
+
706
+
707
+
708
+ </h3><div class="docstring">
709
+ <div class="discussion">
710
+ <p>Validates a request according to JSON API.</p>
711
+
712
+
713
+ </div>
714
+ </div>
715
+ <div class="tags">
716
+
717
+
718
+ </div><table class="source_code">
719
+ <tr>
720
+ <td>
721
+ <pre class="lines">
722
+
723
+
724
+ 24
725
+ 25
726
+ 26
727
+ 27
728
+ 28
729
+ 29
730
+ 30
731
+ 31
732
+ 32
733
+ 33
734
+ 34</pre>
735
+ </td>
736
+ <td>
737
+ <pre class="code"><span class="info file"># File 'lib/apes/concerns/request.rb', line 24</span>
738
+
739
+ <span class='kw'>def</span> <span class='id identifier rubyid_request_validate'>request_validate</span>
740
+ <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>
741
+ <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>
742
+ <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'>Apes</span><span class='op'>::</span><span class='const'>RuntimeConfiguration</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>
743
+
744
+ <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>
745
+
746
+ <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>
747
+
748
+ <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>
749
+ <span class='kw'>end</span></pre>
750
+ </td>
751
+ </tr>
752
+ </table>
753
+ </div>
754
+
755
+ </div>
756
+
757
+ </div>
758
+
759
+ <div id="footer">
760
+ Generated on Sat Jun 4 12:41:53 2016 by
761
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
762
+ 0.8.7.6 (ruby-2.3.0).
763
+ </div>
764
+
765
+ </body>
766
+ </html>