ballast 2.2.4 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,1522 +0,0 @@
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
- Class: Ballast::Service
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/Service.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 (S)</a> &raquo;
35
- <span class='title'><span class='object_link'><a href="../Ballast.html" title="Ballast (module)">Ballast</a></span></span>
36
- &raquo;
37
- <span class="title">Service</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>Class: Ballast::Service
67
-
68
-
69
-
70
- </h1>
71
-
72
- <dl class="box">
73
-
74
- <dt class="r1">Inherits:</dt>
75
- <dd class="r1">
76
- <span class="inheritName">Object</span>
77
-
78
- <ul class="fullTree">
79
- <li>Object</li>
80
-
81
- <li class="next">Ballast::Service</li>
82
-
83
- </ul>
84
- <a href="#" class="inheritanceTree">show all</a>
85
-
86
- </dd>
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
- <dt class="r2 last">Defined in:</dt>
97
- <dd class="r2 last">lib/ballast/service.rb</dd>
98
-
99
- </dl>
100
- <div class="clear"></div>
101
-
102
- <h2>Overview</h2><div class="docstring">
103
- <div class="discussion">
104
- <p>A class which implements a common abstraction for services.</p>
105
-
106
-
107
- </div>
108
- </div>
109
- <div class="tags">
110
-
111
-
112
- </div><h2>Defined Under Namespace</h2>
113
- <p class="children">
114
-
115
-
116
-
117
-
118
- <strong class="classes">Classes:</strong> <span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span>
119
-
120
-
121
- </p>
122
-
123
-
124
-
125
-
126
- <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
127
- <ul class="summary">
128
-
129
- <li class="public ">
130
- <span class="summary_signature">
131
-
132
- <a href="#owner-instance_method" title="#owner (instance method)">- (Object|NilClass) <strong>owner</strong> </a>
133
-
134
-
135
-
136
- </span>
137
-
138
-
139
-
140
-
141
- <span class="note title readonly">readonly</span>
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
- <span class="summary_desc"><div class='inline'><p>The owner of this service.</p>
152
- </div></span>
153
-
154
- </li>
155
-
156
-
157
- </ul>
158
-
159
-
160
-
161
-
162
-
163
- <h2>
164
- Class Method Summary
165
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
166
- </h2>
167
-
168
- <ul class="summary">
169
-
170
- <li class="public ">
171
- <span class="summary_signature">
172
-
173
- <a href="#call-class_method" title="call (class method)">+ (Response) <strong>call</strong>(operation = :perform, owner: nil, raise_errors: false, params: {}, **kwargs, &amp;block) </a>
174
-
175
-
176
-
177
- </span>
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
- <span class="summary_desc"><div class='inline'><p>Invokes one of the operations exposed by the service.</p>
188
- </div></span>
189
-
190
- </li>
191
-
192
-
193
- <li class="public ">
194
- <span class="summary_signature">
195
-
196
- <a href="#fail%21-class_method" title="fail! (class method)">+ (Object) <strong>fail!</strong>(details) </a>
197
-
198
-
199
-
200
- </span>
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
- <span class="summary_desc"><div class='inline'><p>Marks the failure of the operation.</p>
211
- </div></span>
212
-
213
- </li>
214
-
215
-
216
- <li class="public ">
217
- <span class="summary_signature">
218
-
219
- <a href="#fail_validation%21-class_method" title="fail_validation! (class method)">+ (Object) <strong>fail_validation!</strong>(details) </a>
220
-
221
-
222
-
223
- </span>
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
- <span class="summary_desc"><div class='inline'><p>Marks the failure of the validation of the operation.</p>
234
- </div></span>
235
-
236
- </li>
237
-
238
-
239
- <li class="public ">
240
- <span class="summary_signature">
241
-
242
- <a href="#handle_failure-class_method" title="handle_failure (class method)">+ (Response) <strong>handle_failure</strong>(failure, raise_errors) </a>
243
-
244
-
245
-
246
- </span>
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
- <span class="summary_desc"><div class='inline'><p>Handles a failure.</p>
257
- </div></span>
258
-
259
- </li>
260
-
261
-
262
- </ul>
263
-
264
- <h2>
265
- Instance Method Summary
266
- <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
267
- </h2>
268
-
269
- <ul class="summary">
270
-
271
- <li class="public ">
272
- <span class="summary_signature">
273
-
274
- <a href="#call-instance_method" title="#call (instance method)">- (Response) <strong>call</strong>(operation = :perform, owner: nil, raise_errors: false, params: {}, **kwargs, &amp;block) </a>
275
-
276
-
277
-
278
- </span>
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
- <span class="summary_desc"><div class='inline'><p>Invokes one of the operations exposed by the service.</p>
289
- </div></span>
290
-
291
- </li>
292
-
293
-
294
- <li class="public ">
295
- <span class="summary_signature">
296
-
297
- <a href="#fail%21-instance_method" title="#fail! (instance method)">- (Object) <strong>fail!</strong>(details) </a>
298
-
299
-
300
-
301
- </span>
302
-
303
-
304
-
305
-
306
-
307
-
308
-
309
-
310
-
311
- <span class="summary_desc"><div class='inline'><p>Marks the failure of the operation.</p>
312
- </div></span>
313
-
314
- </li>
315
-
316
-
317
- <li class="public ">
318
- <span class="summary_signature">
319
-
320
- <a href="#fail_validation%21-instance_method" title="#fail_validation! (instance method)">- (Object) <strong>fail_validation!</strong>(details) </a>
321
-
322
-
323
-
324
- </span>
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
- <span class="summary_desc"><div class='inline'><p>Marks the failure of the validation of the operation.</p>
335
- </div></span>
336
-
337
- </li>
338
-
339
-
340
- <li class="public ">
341
- <span class="summary_signature">
342
-
343
- <a href="#initialize-instance_method" title="#initialize (instance method)">- (Service) <strong>initialize</strong>(owner = nil) </a>
344
-
345
-
346
-
347
- </span>
348
-
349
-
350
- <span class="note title constructor">constructor</span>
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
- <span class="summary_desc"><div class='inline'><p>Creates a service object.</p>
360
- </div></span>
361
-
362
- </li>
363
-
364
-
365
- </ul>
366
-
367
-
368
- <div id="constructor_details" class="method_details_list">
369
- <h2>Constructor Details</h2>
370
-
371
- <div class="method_details first">
372
- <h3 class="signature first" id="initialize-instance_method">
373
-
374
- - (<tt><span class='object_link'><a href="" title="Ballast::Service (class)">Service</a></span></tt>) <strong>initialize</strong>(owner = nil)
375
-
376
-
377
-
378
-
379
-
380
- </h3><div class="docstring">
381
- <div class="discussion">
382
- <p>Creates a service object.</p>
383
-
384
-
385
- </div>
386
- </div>
387
- <div class="tags">
388
- <p class="tag_title">Parameters:</p>
389
- <ul class="param">
390
-
391
- <li>
392
-
393
- <span class='name'>owner</span>
394
-
395
-
396
- <span class='type'>(<tt>Object|NilClass</tt>)</span>
397
-
398
-
399
- <em class="default">(defaults to: <tt>nil</tt>)</em>
400
-
401
-
402
- &mdash;
403
- <div class='inline'><p>The owner of the service.</p>
404
- </div>
405
-
406
- </li>
407
-
408
- </ul>
409
-
410
-
411
- </div><table class="source_code">
412
- <tr>
413
- <td>
414
- <pre class="lines">
415
-
416
-
417
- 115
418
- 116
419
- 117</pre>
420
- </td>
421
- <td>
422
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 115</span>
423
-
424
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_owner identifier id'>owner</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
425
- <span class='rubyid_@owner ivar id'>@owner</span> <span class='assign token'>=</span> <span class='rubyid_owner identifier id'>owner</span>
426
- <span class='rubyid_end end kw'>end</span>
427
- </pre>
428
- </td>
429
- </tr>
430
- </table>
431
- </div>
432
-
433
- </div>
434
-
435
- <div id="instance_attr_details" class="attr_details">
436
- <h2>Instance Attribute Details</h2>
437
-
438
-
439
- <span id=""></span>
440
- <div class="method_details first">
441
- <h3 class="signature first" id="owner-instance_method">
442
-
443
- - (<tt>Object|NilClass</tt>) <strong>owner</strong> <span class="extras">(readonly)</span>
444
-
445
-
446
-
447
-
448
-
449
- </h3><div class="docstring">
450
- <div class="discussion">
451
- <p>Returns The owner of this service.</p>
452
-
453
-
454
- </div>
455
- </div>
456
- <div class="tags">
457
-
458
- <p class="tag_title">Returns:</p>
459
- <ul class="return">
460
-
461
- <li>
462
-
463
-
464
- <span class='type'>(<tt>Object|NilClass</tt>)</span>
465
-
466
-
467
-
468
- &mdash;
469
- <div class='inline'><p>The owner of this service.</p>
470
- </div>
471
-
472
- </li>
473
-
474
- </ul>
475
-
476
- </div><table class="source_code">
477
- <tr>
478
- <td>
479
- <pre class="lines">
480
-
481
-
482
- 11
483
- 12
484
- 13
485
- 14
486
- 15
487
- 16
488
- 17
489
- 18
490
- 19
491
- 20
492
- 21
493
- 22
494
- 23
495
- 24
496
- 25
497
- 26
498
- 27
499
- 28
500
- 29
501
- 30
502
- 31
503
- 32
504
- 33
505
- 34
506
- 35
507
- 36
508
- 37
509
- 38
510
- 39
511
- 40
512
- 41
513
- 42
514
- 43
515
- 44
516
- 45
517
- 46
518
- 47
519
- 48
520
- 49
521
- 50
522
- 51
523
- 52
524
- 53
525
- 54
526
- 55
527
- 56
528
- 57
529
- 58
530
- 59
531
- 60
532
- 61
533
- 62
534
- 63
535
- 64
536
- 65
537
- 66
538
- 67
539
- 68
540
- 69
541
- 70
542
- 71
543
- 72
544
- 73
545
- 74
546
- 75
547
- 76
548
- 77
549
- 78
550
- 79
551
- 80
552
- 81
553
- 82
554
- 83
555
- 84
556
- 85
557
- 86
558
- 87
559
- 88
560
- 89
561
- 90
562
- 91
563
- 92
564
- 93
565
- 94
566
- 95
567
- 96
568
- 97
569
- 98
570
- 99
571
- 100
572
- 101
573
- 102
574
- 103
575
- 104
576
- 105
577
- 106
578
- 107
579
- 108
580
- 109
581
- 110
582
- 111
583
- 112
584
- 113
585
- 114
586
- 115
587
- 116
588
- 117
589
- 118
590
- 119
591
- 120
592
- 121
593
- 122
594
- 123
595
- 124
596
- 125
597
- 126
598
- 127
599
- 128
600
- 129
601
- 130
602
- 131
603
- 132
604
- 133
605
- 134
606
- 135
607
- 136
608
- 137
609
- 138
610
- 139
611
- 140
612
- 141
613
- 142
614
- 143
615
- 144
616
- 145
617
- 146
618
- 147
619
- 148
620
- 149
621
- 150
622
- 151
623
- 152
624
- 153
625
- 154
626
- 155
627
- 156
628
- 157
629
- 158
630
- 159</pre>
631
- </td>
632
- <td>
633
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 11</span>
634
-
635
- <span class='rubyid_class class kw'>class</span> <span class='rubyid_Service constant id'>Service</span>
636
- <span class='comment val'># A response to a service invocation.</span>
637
- <span class='comment val'>#</span>
638
- <span class='comment val'># @attribute [r] success</span>
639
- <span class='comment val'># @return [Boolean] Whether the invocation was successful or not.</span>
640
- <span class='comment val'># @attribute [r] data</span>
641
- <span class='comment val'># @return [Object] The data returned by the operation.</span>
642
- <span class='comment val'># @attribute [r] errors</span>
643
- <span class='comment val'># @return [Array] The errors returned by the operation.</span>
644
- <span class='rubyid_class class kw'>class</span> <span class='rubyid_Response constant id'>Response</span>
645
- <span class='rubyid_attr_reader identifier id'>attr_reader</span> <span class='symbol val'>:success</span><span class='comma token'>,</span> <span class='symbol val'>:data</span><span class='comma token'>,</span> <span class='symbol val'>:errors</span>
646
-
647
- <span class='comment val'># Creates a new service response.</span>
648
- <span class='comment val'>#</span>
649
- <span class='comment val'># @param success [Boolean] Whether the invocation was successful or not.</span>
650
- <span class='comment val'># @param data [Object|NilClass] The data returned by the operation.</span>
651
- <span class='comment val'># @param errors [Array|NilClass] The errors returned by the operation.</span>
652
- <span class='comment val'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*</span>
653
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_success identifier id'>success</span> <span class='assign token'>=</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>errors:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
654
- <span class='rubyid_errors identifier id'>errors</span> <span class='opasgn op'>||=</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span>
655
-
656
- <span class='rubyid_@success ivar id'>@success</span> <span class='assign token'>=</span> <span class='rubyid_success identifier id'>success</span><span class='dot token'>.</span><span class='rubyid_to_boolean identifier id'>to_boolean</span>
657
- <span class='rubyid_@data ivar id'>@data</span> <span class='assign token'>=</span> <span class='rubyid_data identifier id'>data</span>
658
- <span class='rubyid_@errors ivar id'>@errors</span> <span class='assign token'>=</span> <span class='rubyid_errors identifier id'>errors</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span><span class='lparen token'>(</span><span class='label val'>no_duplicates:</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>compact:</span> <span class='rubyid_true true kw'>true</span><span class='rparen token'>)</span>
659
- <span class='rubyid_end end kw'>end</span>
660
-
661
- <span class='comment val'># Returns whether the invocation was successful or not.</span>
662
- <span class='comment val'>#</span>
663
- <span class='comment val'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.</span>
664
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_success? fid id'>success?</span>
665
- <span class='comment val'># TODO@PI: Ignore rubocop on this</span>
666
- <span class='rubyid_@success ivar id'>@success</span>
667
- <span class='rubyid_end end kw'>end</span>
668
- <span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:successful?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
669
- <span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:succeeded?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
670
-
671
- <span class='comment val'># Returns whether the invocation failed or not.</span>
672
- <span class='comment val'>#</span>
673
- <span class='comment val'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.</span>
674
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_fail? fid id'>fail?</span>
675
- <span class='notop op'>!</span><span class='rubyid_@success ivar id'>@success</span>
676
- <span class='rubyid_end end kw'>end</span>
677
- <span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:failed?</span><span class='comma token'>,</span> <span class='symbol val'>:fail?</span>
678
-
679
- <span class='comment val'># Returns the first error returned by the operation.</span>
680
- <span class='comment val'>#</span>
681
- <span class='comment val'># @return [Object] The first error returned by the service.</span>
682
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_error identifier id'>error</span>
683
- <span class='rubyid_@errors ivar id'>@errors</span><span class='dot token'>.</span><span class='rubyid_first identifier id'>first</span>
684
- <span class='rubyid_end end kw'>end</span>
685
-
686
- <span class='comment val'># Converts this response to a AJAX response.</span>
687
- <span class='comment val'>#</span>
688
- <span class='comment val'># @param transport [Object|NilClass] The transport to use for sending. Must respond to `render`, `params`, `request.format` and `performed?`.</span>
689
- <span class='comment val'># @return [AjaxResponse] The AJAX response, which will include only the first error.</span>
690
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_as_ajax_response identifier id'>as_ajax_response</span><span class='lparen token'>(</span><span class='rubyid_transport identifier id'>transport</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
691
- <span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='rubyid_error_message identifier id'>error_message</span> <span class='assign token'>=</span>
692
- <span class='rubyid_if if kw'>if</span> <span class='rubyid_successful? fid id'>successful?</span>
693
- <span class='lbrack token'>[</span><span class='symbol val'>:ok</span><span class='comma token'>,</span> <span class='rubyid_nil nil kw'>nil</span><span class='rbrack token'>]</span>
694
- <span class='rubyid_elsif elsif kw'>elsif</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Hash constant id'>Hash</span><span class='rparen token'>)</span>
695
- <span class='lbrack token'>[</span><span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:status</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
696
- <span class='rubyid_else else kw'>else</span>
697
- <span class='lbrack token'>[</span><span class='symbol val'>:unknown</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='rbrack token'>]</span>
698
- <span class='rubyid_end end kw'>end</span>
699
-
700
- <span class='rubyid_AjaxResponse constant id'>AjaxResponse</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_data identifier id'>data</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_error_message identifier id'>error_message</span><span class='comma token'>,</span> <span class='label val'>transport:</span> <span class='rubyid_transport identifier id'>transport</span><span class='rparen token'>)</span>
701
- <span class='rubyid_end end kw'>end</span>
702
- <span class='rubyid_end end kw'>end</span>
703
-
704
- <span class='rubyid_attr_reader identifier id'>attr_reader</span> <span class='symbol val'>:owner</span>
705
-
706
- <span class='comment val'># Invokes one of the operations exposed by the service.</span>
707
- <span class='comment val'>#</span>
708
- <span class='comment val'># @param operation [String] The operation to invoke.</span>
709
- <span class='comment val'># @param owner [Object|NilClass] The owner of the service.</span>
710
- <span class='comment val'># @param raise_errors [Boolean] Whether to raise errors instead of returning a failure.</span>
711
- <span class='comment val'># @param params [Hash] The parameters to pass to the service.</span>
712
- <span class='comment val'># @param kwargs [Hash] Other modifiers to pass to the service.</span>
713
- <span class='comment val'># @param block [Proc] A lambda to pass to the service.</span>
714
- <span class='comment val'># @return [Response] The response of the service.</span>
715
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_call identifier id'>call</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span> <span class='assign token'>=</span> <span class='symbol val'>:perform</span><span class='comma token'>,</span> <span class='label val'>owner:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>raise_errors:</span> <span class='rubyid_false false kw'>false</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
716
- <span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='integer val'>501</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='dstring node'>&quot;Unsupported operation #{self}.#{operation}.&quot;</span><span class='rparen token'>)</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_respond_to? fid id'>respond_to?</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='rparen token'>)</span>
717
- <span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='comma token'>,</span> <span class='label val'>owner:</span> <span class='rubyid_owner identifier id'>owner</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='rubyid_params identifier id'>params</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
718
- <span class='rubyid_rescue rescue kw'>rescue</span> <span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='rubyid_failure identifier id'>failure</span>
719
- <span class='rubyid_handle_failure identifier id'>handle_failure</span><span class='lparen token'>(</span><span class='rubyid_failure identifier id'>failure</span><span class='comma token'>,</span> <span class='rubyid_raise_errors identifier id'>raise_errors</span><span class='rparen token'>)</span>
720
- <span class='rubyid_end end kw'>end</span>
721
-
722
- <span class='comment val'># Marks the failure of the operation.</span>
723
- <span class='comment val'>#</span>
724
- <span class='comment val'># @param details [Object] The error(s) occurred.</span>
725
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
726
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
727
- <span class='rubyid_end end kw'>end</span>
728
-
729
- <span class='comment val'># Marks the failure of the validation of the operation.</span>
730
- <span class='comment val'>#</span>
731
- <span class='comment val'># @param details [Object] The error(s) occurred.</span>
732
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_fail_validation! fid id'>fail_validation!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
733
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_ValidationFailure constant id'>ValidationFailure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
734
- <span class='rubyid_end end kw'>end</span>
735
-
736
- <span class='comment val'># Creates a service object.</span>
737
- <span class='comment val'>#</span>
738
- <span class='comment val'># @param owner [Object|NilClass] The owner of the service.</span>
739
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_owner identifier id'>owner</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
740
- <span class='rubyid_@owner ivar id'>@owner</span> <span class='assign token'>=</span> <span class='rubyid_owner identifier id'>owner</span>
741
- <span class='rubyid_end end kw'>end</span>
742
-
743
- <span class='comment val'># Invokes one of the operations exposed by the service.</span>
744
- <span class='comment val'>#</span>
745
- <span class='comment val'># @param operation [String] The operation to invoke.</span>
746
- <span class='comment val'># @param owner [Object|NilClass] The owner of the service.</span>
747
- <span class='comment val'># @param raise_errors [Boolean] Whether to raise errors instead of returning a failure.</span>
748
- <span class='comment val'># @param params [Hash] The parameters to pass to the service.</span>
749
- <span class='comment val'># @param kwargs [Hash] Other modifiers to pass to the service.</span>
750
- <span class='comment val'># @param block [Proc] A lambda to pass to the service.</span>
751
- <span class='comment val'># @return [Response] The response of the service.</span>
752
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_call identifier id'>call</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span> <span class='assign token'>=</span> <span class='symbol val'>:perform</span><span class='comma token'>,</span> <span class='label val'>owner:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>raise_errors:</span> <span class='rubyid_false false kw'>false</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
753
- <span class='comment val'># PI: Ignore Roodi on this method</span>
754
- <span class='rubyid_@owner ivar id'>@owner</span> <span class='assign token'>=</span> <span class='rubyid_owner identifier id'>owner</span> <span class='rubyid_if if_mod kw'>if</span> <span class='rubyid_owner identifier id'>owner</span>
755
- <span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='integer val'>501</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='dstring node'>&quot;Unsupported operation #{self.class}##{operation}.&quot;</span><span class='rparen token'>)</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_respond_to? fid id'>respond_to?</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='rparen token'>)</span>
756
- <span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='rubyid_params identifier id'>params</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
757
- <span class='rubyid_rescue rescue kw'>rescue</span> <span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='rubyid_failure identifier id'>failure</span>
758
- <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_class identifier id'>class</span><span class='dot token'>.</span><span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='symbol val'>:handle_failure</span><span class='comma token'>,</span> <span class='rubyid_failure identifier id'>failure</span><span class='comma token'>,</span> <span class='rubyid_raise_errors identifier id'>raise_errors</span><span class='rparen token'>)</span>
759
- <span class='rubyid_end end kw'>end</span>
760
-
761
- <span class='comment val'># Marks the failure of the operation.</span>
762
- <span class='comment val'>#</span>
763
- <span class='comment val'># @param details [Object] The error(s) occurred.</span>
764
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
765
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
766
- <span class='rubyid_end end kw'>end</span>
767
-
768
- <span class='comment val'># Marks the failure of the validation of the operation.</span>
769
- <span class='comment val'>#</span>
770
- <span class='comment val'># @param details [Object] The error(s) occurred.</span>
771
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_fail_validation! fid id'>fail_validation!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
772
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_ValidationFailure constant id'>ValidationFailure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
773
- <span class='rubyid_end end kw'>end</span>
774
-
775
- <span class='comment val'># Handles a failure.</span>
776
- <span class='comment val'>#</span>
777
- <span class='comment val'># @param failure [Failure] The failure to handle.</span>
778
- <span class='comment val'># @param raise_errors [Boolean] If `true` it will simply raise the error, otherwise it will return a failure as as Service::Response.</span>
779
- <span class='comment val'># @return [Response] A failure response.</span>
780
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_handle_failure identifier id'>handle_failure</span><span class='lparen token'>(</span><span class='rubyid_failure identifier id'>failure</span><span class='comma token'>,</span> <span class='rubyid_raise_errors identifier id'>raise_errors</span><span class='rparen token'>)</span>
781
- <span class='rubyid_raise_errors identifier id'>raise_errors</span> <span class='integer val'>? </span><span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_failure identifier id'>failure</span><span class='rparen token'>)</span> <span class='colon op'>:</span> <span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_false false kw'>false</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_failure identifier id'>failure</span><span class='dot token'>.</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
782
- <span class='rubyid_end end kw'>end</span>
783
- <span class='rubyid_end end kw'>end</span>
784
- </pre>
785
- </td>
786
- </tr>
787
- </table>
788
- </div>
789
-
790
- </div>
791
-
792
-
793
- <div id="class_method_details" class="method_details_list">
794
- <h2>Class Method Details</h2>
795
-
796
-
797
- <div class="method_details first">
798
- <h3 class="signature first" id="call-class_method">
799
-
800
- + (<tt><span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span></tt>) <strong>call</strong>(operation = :perform, owner: nil, raise_errors: false, params: {}, **kwargs, &amp;block)
801
-
802
-
803
-
804
-
805
-
806
- </h3><div class="docstring">
807
- <div class="discussion">
808
- <p>Invokes one of the operations exposed by the service.</p>
809
-
810
-
811
- </div>
812
- </div>
813
- <div class="tags">
814
- <p class="tag_title">Parameters:</p>
815
- <ul class="param">
816
-
817
- <li>
818
-
819
- <span class='name'>operation</span>
820
-
821
-
822
- <span class='type'>(<tt>String</tt>)</span>
823
-
824
-
825
- <em class="default">(defaults to: <tt>:perform</tt>)</em>
826
-
827
-
828
- &mdash;
829
- <div class='inline'><p>The operation to invoke.</p>
830
- </div>
831
-
832
- </li>
833
-
834
- <li>
835
-
836
- <span class='name'>owner</span>
837
-
838
-
839
- <span class='type'>(<tt>Object|NilClass</tt>)</span>
840
-
841
-
842
-
843
- &mdash;
844
- <div class='inline'><p>The owner of the service.</p>
845
- </div>
846
-
847
- </li>
848
-
849
- <li>
850
-
851
- <span class='name'>raise_errors</span>
852
-
853
-
854
- <span class='type'>(<tt>Boolean</tt>)</span>
855
-
856
-
857
-
858
- &mdash;
859
- <div class='inline'><p>Whether to raise errors instead of returning a failure.</p>
860
- </div>
861
-
862
- </li>
863
-
864
- <li>
865
-
866
- <span class='name'>params</span>
867
-
868
-
869
- <span class='type'>(<tt>Hash</tt>)</span>
870
-
871
-
872
-
873
- &mdash;
874
- <div class='inline'><p>The parameters to pass to the service.</p>
875
- </div>
876
-
877
- </li>
878
-
879
- <li>
880
-
881
- <span class='name'>kwargs</span>
882
-
883
-
884
- <span class='type'>(<tt>Hash</tt>)</span>
885
-
886
-
887
-
888
- &mdash;
889
- <div class='inline'><p>Other modifiers to pass to the service.</p>
890
- </div>
891
-
892
- </li>
893
-
894
- <li>
895
-
896
- <span class='name'>block</span>
897
-
898
-
899
- <span class='type'>(<tt>Proc</tt>)</span>
900
-
901
-
902
-
903
- &mdash;
904
- <div class='inline'><p>A lambda to pass to the service.</p>
905
- </div>
906
-
907
- </li>
908
-
909
- </ul>
910
-
911
- <p class="tag_title">Returns:</p>
912
- <ul class="return">
913
-
914
- <li>
915
-
916
-
917
- <span class='type'>(<tt><span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span></tt>)</span>
918
-
919
-
920
-
921
- &mdash;
922
- <div class='inline'><p>The response of the service.</p>
923
- </div>
924
-
925
- </li>
926
-
927
- </ul>
928
-
929
- </div><table class="source_code">
930
- <tr>
931
- <td>
932
- <pre class="lines">
933
-
934
-
935
- 91
936
- 92
937
- 93
938
- 94
939
- 95
940
- 96</pre>
941
- </td>
942
- <td>
943
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 91</span>
944
-
945
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_call identifier id'>call</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span> <span class='assign token'>=</span> <span class='symbol val'>:perform</span><span class='comma token'>,</span> <span class='label val'>owner:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>raise_errors:</span> <span class='rubyid_false false kw'>false</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
946
- <span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='integer val'>501</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='dstring node'>&quot;Unsupported operation #{self}.#{operation}.&quot;</span><span class='rparen token'>)</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_respond_to? fid id'>respond_to?</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='rparen token'>)</span>
947
- <span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='comma token'>,</span> <span class='label val'>owner:</span> <span class='rubyid_owner identifier id'>owner</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='rubyid_params identifier id'>params</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
948
- <span class='rubyid_rescue rescue kw'>rescue</span> <span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='rubyid_failure identifier id'>failure</span>
949
- <span class='rubyid_handle_failure identifier id'>handle_failure</span><span class='lparen token'>(</span><span class='rubyid_failure identifier id'>failure</span><span class='comma token'>,</span> <span class='rubyid_raise_errors identifier id'>raise_errors</span><span class='rparen token'>)</span>
950
- <span class='rubyid_end end kw'>end</span>
951
- </pre>
952
- </td>
953
- </tr>
954
- </table>
955
- </div>
956
-
957
- <div class="method_details ">
958
- <h3 class="signature " id="fail!-class_method">
959
-
960
- + (<tt>Object</tt>) <strong>fail!</strong>(details)
961
-
962
-
963
-
964
-
965
-
966
- </h3><div class="docstring">
967
- <div class="discussion">
968
- <p>Marks the failure of the operation.</p>
969
-
970
-
971
- </div>
972
- </div>
973
- <div class="tags">
974
- <p class="tag_title">Parameters:</p>
975
- <ul class="param">
976
-
977
- <li>
978
-
979
- <span class='name'>details</span>
980
-
981
-
982
- <span class='type'>(<tt>Object</tt>)</span>
983
-
984
-
985
-
986
- &mdash;
987
- <div class='inline'><p>The error(s) occurred.</p>
988
- </div>
989
-
990
- </li>
991
-
992
- </ul>
993
-
994
- <p class="tag_title">Raises:</p>
995
- <ul class="raise">
996
-
997
- <li>
998
-
999
-
1000
- <span class='type'>(<tt><span class='object_link'><a href="Errors/Failure.html" title="Ballast::Errors::Failure (class)">Errors::Failure</a></span></tt>)</span>
1001
-
1002
-
1003
-
1004
- </li>
1005
-
1006
- </ul>
1007
-
1008
- </div><table class="source_code">
1009
- <tr>
1010
- <td>
1011
- <pre class="lines">
1012
-
1013
-
1014
- 101
1015
- 102
1016
- 103</pre>
1017
- </td>
1018
- <td>
1019
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 101</span>
1020
-
1021
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1022
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1023
- <span class='rubyid_end end kw'>end</span>
1024
- </pre>
1025
- </td>
1026
- </tr>
1027
- </table>
1028
- </div>
1029
-
1030
- <div class="method_details ">
1031
- <h3 class="signature " id="fail_validation!-class_method">
1032
-
1033
- + (<tt>Object</tt>) <strong>fail_validation!</strong>(details)
1034
-
1035
-
1036
-
1037
-
1038
-
1039
- </h3><div class="docstring">
1040
- <div class="discussion">
1041
- <p>Marks the failure of the validation of the operation.</p>
1042
-
1043
-
1044
- </div>
1045
- </div>
1046
- <div class="tags">
1047
- <p class="tag_title">Parameters:</p>
1048
- <ul class="param">
1049
-
1050
- <li>
1051
-
1052
- <span class='name'>details</span>
1053
-
1054
-
1055
- <span class='type'>(<tt>Object</tt>)</span>
1056
-
1057
-
1058
-
1059
- &mdash;
1060
- <div class='inline'><p>The error(s) occurred.</p>
1061
- </div>
1062
-
1063
- </li>
1064
-
1065
- </ul>
1066
-
1067
- <p class="tag_title">Raises:</p>
1068
- <ul class="raise">
1069
-
1070
- <li>
1071
-
1072
-
1073
- <span class='type'>(<tt><span class='object_link'><a href="Errors/ValidationFailure.html" title="Ballast::Errors::ValidationFailure (class)">Errors::ValidationFailure</a></span></tt>)</span>
1074
-
1075
-
1076
-
1077
- </li>
1078
-
1079
- </ul>
1080
-
1081
- </div><table class="source_code">
1082
- <tr>
1083
- <td>
1084
- <pre class="lines">
1085
-
1086
-
1087
- 108
1088
- 109
1089
- 110</pre>
1090
- </td>
1091
- <td>
1092
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 108</span>
1093
-
1094
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_fail_validation! fid id'>fail_validation!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1095
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_ValidationFailure constant id'>ValidationFailure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1096
- <span class='rubyid_end end kw'>end</span>
1097
- </pre>
1098
- </td>
1099
- </tr>
1100
- </table>
1101
- </div>
1102
-
1103
- <div class="method_details ">
1104
- <h3 class="signature " id="handle_failure-class_method">
1105
-
1106
- + (<tt><span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span></tt>) <strong>handle_failure</strong>(failure, raise_errors)
1107
-
1108
-
1109
-
1110
-
1111
-
1112
- </h3><div class="docstring">
1113
- <div class="discussion">
1114
- <p>Handles a failure.</p>
1115
-
1116
-
1117
- </div>
1118
- </div>
1119
- <div class="tags">
1120
- <p class="tag_title">Parameters:</p>
1121
- <ul class="param">
1122
-
1123
- <li>
1124
-
1125
- <span class='name'>failure</span>
1126
-
1127
-
1128
- <span class='type'>(<tt>Failure</tt>)</span>
1129
-
1130
-
1131
-
1132
- &mdash;
1133
- <div class='inline'><p>The failure to handle.</p>
1134
- </div>
1135
-
1136
- </li>
1137
-
1138
- <li>
1139
-
1140
- <span class='name'>raise_errors</span>
1141
-
1142
-
1143
- <span class='type'>(<tt>Boolean</tt>)</span>
1144
-
1145
-
1146
-
1147
- &mdash;
1148
- <div class='inline'><p>If <code>true</code> it will simply raise the error, otherwise it will return a failure as as Service::Response.</p>
1149
- </div>
1150
-
1151
- </li>
1152
-
1153
- </ul>
1154
-
1155
- <p class="tag_title">Returns:</p>
1156
- <ul class="return">
1157
-
1158
- <li>
1159
-
1160
-
1161
- <span class='type'>(<tt><span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span></tt>)</span>
1162
-
1163
-
1164
-
1165
- &mdash;
1166
- <div class='inline'><p>A failure response.</p>
1167
- </div>
1168
-
1169
- </li>
1170
-
1171
- </ul>
1172
-
1173
- </div><table class="source_code">
1174
- <tr>
1175
- <td>
1176
- <pre class="lines">
1177
-
1178
-
1179
- 156
1180
- 157
1181
- 158</pre>
1182
- </td>
1183
- <td>
1184
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 156</span>
1185
-
1186
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_handle_failure identifier id'>handle_failure</span><span class='lparen token'>(</span><span class='rubyid_failure identifier id'>failure</span><span class='comma token'>,</span> <span class='rubyid_raise_errors identifier id'>raise_errors</span><span class='rparen token'>)</span>
1187
- <span class='rubyid_raise_errors identifier id'>raise_errors</span> <span class='integer val'>? </span><span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_failure identifier id'>failure</span><span class='rparen token'>)</span> <span class='colon op'>:</span> <span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_false false kw'>false</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_failure identifier id'>failure</span><span class='dot token'>.</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1188
- <span class='rubyid_end end kw'>end</span>
1189
- </pre>
1190
- </td>
1191
- </tr>
1192
- </table>
1193
- </div>
1194
-
1195
- </div>
1196
-
1197
- <div id="instance_method_details" class="method_details_list">
1198
- <h2>Instance Method Details</h2>
1199
-
1200
-
1201
- <div class="method_details first">
1202
- <h3 class="signature first" id="call-instance_method">
1203
-
1204
- - (<tt><span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span></tt>) <strong>call</strong>(operation = :perform, owner: nil, raise_errors: false, params: {}, **kwargs, &amp;block)
1205
-
1206
-
1207
-
1208
-
1209
-
1210
- </h3><div class="docstring">
1211
- <div class="discussion">
1212
- <p>Invokes one of the operations exposed by the service.</p>
1213
-
1214
-
1215
- </div>
1216
- </div>
1217
- <div class="tags">
1218
- <p class="tag_title">Parameters:</p>
1219
- <ul class="param">
1220
-
1221
- <li>
1222
-
1223
- <span class='name'>operation</span>
1224
-
1225
-
1226
- <span class='type'>(<tt>String</tt>)</span>
1227
-
1228
-
1229
- <em class="default">(defaults to: <tt>:perform</tt>)</em>
1230
-
1231
-
1232
- &mdash;
1233
- <div class='inline'><p>The operation to invoke.</p>
1234
- </div>
1235
-
1236
- </li>
1237
-
1238
- <li>
1239
-
1240
- <span class='name'>owner</span>
1241
-
1242
-
1243
- <span class='type'>(<tt>Object|NilClass</tt>)</span>
1244
-
1245
-
1246
-
1247
- &mdash;
1248
- <div class='inline'><p>The owner of the service.</p>
1249
- </div>
1250
-
1251
- </li>
1252
-
1253
- <li>
1254
-
1255
- <span class='name'>raise_errors</span>
1256
-
1257
-
1258
- <span class='type'>(<tt>Boolean</tt>)</span>
1259
-
1260
-
1261
-
1262
- &mdash;
1263
- <div class='inline'><p>Whether to raise errors instead of returning a failure.</p>
1264
- </div>
1265
-
1266
- </li>
1267
-
1268
- <li>
1269
-
1270
- <span class='name'>params</span>
1271
-
1272
-
1273
- <span class='type'>(<tt>Hash</tt>)</span>
1274
-
1275
-
1276
-
1277
- &mdash;
1278
- <div class='inline'><p>The parameters to pass to the service.</p>
1279
- </div>
1280
-
1281
- </li>
1282
-
1283
- <li>
1284
-
1285
- <span class='name'>kwargs</span>
1286
-
1287
-
1288
- <span class='type'>(<tt>Hash</tt>)</span>
1289
-
1290
-
1291
-
1292
- &mdash;
1293
- <div class='inline'><p>Other modifiers to pass to the service.</p>
1294
- </div>
1295
-
1296
- </li>
1297
-
1298
- <li>
1299
-
1300
- <span class='name'>block</span>
1301
-
1302
-
1303
- <span class='type'>(<tt>Proc</tt>)</span>
1304
-
1305
-
1306
-
1307
- &mdash;
1308
- <div class='inline'><p>A lambda to pass to the service.</p>
1309
- </div>
1310
-
1311
- </li>
1312
-
1313
- </ul>
1314
-
1315
- <p class="tag_title">Returns:</p>
1316
- <ul class="return">
1317
-
1318
- <li>
1319
-
1320
-
1321
- <span class='type'>(<tt><span class='object_link'><a href="Service/Response.html" title="Ballast::Service::Response (class)">Response</a></span></tt>)</span>
1322
-
1323
-
1324
-
1325
- &mdash;
1326
- <div class='inline'><p>The response of the service.</p>
1327
- </div>
1328
-
1329
- </li>
1330
-
1331
- </ul>
1332
-
1333
- </div><table class="source_code">
1334
- <tr>
1335
- <td>
1336
- <pre class="lines">
1337
-
1338
-
1339
- 128
1340
- 129
1341
- 130
1342
- 131
1343
- 132
1344
- 133
1345
- 134
1346
- 135</pre>
1347
- </td>
1348
- <td>
1349
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 128</span>
1350
-
1351
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_call identifier id'>call</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span> <span class='assign token'>=</span> <span class='symbol val'>:perform</span><span class='comma token'>,</span> <span class='label val'>owner:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>raise_errors:</span> <span class='rubyid_false false kw'>false</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='lbrace token'>{</span><span class='rbrace token'>}</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span>
1352
- <span class='comment val'># PI: Ignore Roodi on this method</span>
1353
- <span class='rubyid_@owner ivar id'>@owner</span> <span class='assign token'>=</span> <span class='rubyid_owner identifier id'>owner</span> <span class='rubyid_if if_mod kw'>if</span> <span class='rubyid_owner identifier id'>owner</span>
1354
- <span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='integer val'>501</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='dstring node'>&quot;Unsupported operation #{self.class}##{operation}.&quot;</span><span class='rparen token'>)</span> <span class='rubyid_unless unless_mod kw'>unless</span> <span class='rubyid_respond_to? fid id'>respond_to?</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='rparen token'>)</span>
1355
- <span class='rubyid_Response constant id'>Response</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='rubyid_operation identifier id'>operation</span><span class='comma token'>,</span> <span class='label val'>params:</span> <span class='rubyid_params identifier id'>params</span><span class='comma token'>,</span> <span class='pow op'>**</span><span class='rubyid_kwargs identifier id'>kwargs</span><span class='comma token'>,</span> <span class='bitand op'>&amp;</span><span class='rubyid_block identifier id'>block</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
1356
- <span class='rubyid_rescue rescue kw'>rescue</span> <span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span> <span class='assign token'>=</span><span class='gt op'>&gt;</span> <span class='rubyid_failure identifier id'>failure</span>
1357
- <span class='rubyid_self self kw'>self</span><span class='dot token'>.</span><span class='rubyid_class identifier id'>class</span><span class='dot token'>.</span><span class='rubyid_send identifier id'>send</span><span class='lparen token'>(</span><span class='symbol val'>:handle_failure</span><span class='comma token'>,</span> <span class='rubyid_failure identifier id'>failure</span><span class='comma token'>,</span> <span class='rubyid_raise_errors identifier id'>raise_errors</span><span class='rparen token'>)</span>
1358
- <span class='rubyid_end end kw'>end</span>
1359
- </pre>
1360
- </td>
1361
- </tr>
1362
- </table>
1363
- </div>
1364
-
1365
- <div class="method_details ">
1366
- <h3 class="signature " id="fail!-instance_method">
1367
-
1368
- - (<tt>Object</tt>) <strong>fail!</strong>(details)
1369
-
1370
-
1371
-
1372
-
1373
-
1374
- </h3><div class="docstring">
1375
- <div class="discussion">
1376
- <p>Marks the failure of the operation.</p>
1377
-
1378
-
1379
- </div>
1380
- </div>
1381
- <div class="tags">
1382
- <p class="tag_title">Parameters:</p>
1383
- <ul class="param">
1384
-
1385
- <li>
1386
-
1387
- <span class='name'>details</span>
1388
-
1389
-
1390
- <span class='type'>(<tt>Object</tt>)</span>
1391
-
1392
-
1393
-
1394
- &mdash;
1395
- <div class='inline'><p>The error(s) occurred.</p>
1396
- </div>
1397
-
1398
- </li>
1399
-
1400
- </ul>
1401
-
1402
- <p class="tag_title">Raises:</p>
1403
- <ul class="raise">
1404
-
1405
- <li>
1406
-
1407
-
1408
- <span class='type'>(<tt><span class='object_link'><a href="Errors/Failure.html" title="Ballast::Errors::Failure (class)">Errors::Failure</a></span></tt>)</span>
1409
-
1410
-
1411
-
1412
- </li>
1413
-
1414
- </ul>
1415
-
1416
- </div><table class="source_code">
1417
- <tr>
1418
- <td>
1419
- <pre class="lines">
1420
-
1421
-
1422
- 140
1423
- 141
1424
- 142</pre>
1425
- </td>
1426
- <td>
1427
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 140</span>
1428
-
1429
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_fail! fid id'>fail!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1430
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_Failure constant id'>Failure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1431
- <span class='rubyid_end end kw'>end</span>
1432
- </pre>
1433
- </td>
1434
- </tr>
1435
- </table>
1436
- </div>
1437
-
1438
- <div class="method_details ">
1439
- <h3 class="signature " id="fail_validation!-instance_method">
1440
-
1441
- - (<tt>Object</tt>) <strong>fail_validation!</strong>(details)
1442
-
1443
-
1444
-
1445
-
1446
-
1447
- </h3><div class="docstring">
1448
- <div class="discussion">
1449
- <p>Marks the failure of the validation of the operation.</p>
1450
-
1451
-
1452
- </div>
1453
- </div>
1454
- <div class="tags">
1455
- <p class="tag_title">Parameters:</p>
1456
- <ul class="param">
1457
-
1458
- <li>
1459
-
1460
- <span class='name'>details</span>
1461
-
1462
-
1463
- <span class='type'>(<tt>Object</tt>)</span>
1464
-
1465
-
1466
-
1467
- &mdash;
1468
- <div class='inline'><p>The error(s) occurred.</p>
1469
- </div>
1470
-
1471
- </li>
1472
-
1473
- </ul>
1474
-
1475
- <p class="tag_title">Raises:</p>
1476
- <ul class="raise">
1477
-
1478
- <li>
1479
-
1480
-
1481
- <span class='type'>(<tt><span class='object_link'><a href="Errors/ValidationFailure.html" title="Ballast::Errors::ValidationFailure (class)">Errors::ValidationFailure</a></span></tt>)</span>
1482
-
1483
-
1484
-
1485
- </li>
1486
-
1487
- </ul>
1488
-
1489
- </div><table class="source_code">
1490
- <tr>
1491
- <td>
1492
- <pre class="lines">
1493
-
1494
-
1495
- 147
1496
- 148
1497
- 149</pre>
1498
- </td>
1499
- <td>
1500
- <pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 147</span>
1501
-
1502
- <span class='rubyid_def def kw'>def</span> <span class='rubyid_fail_validation! fid id'>fail_validation!</span><span class='lparen token'>(</span><span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1503
- <span class='rubyid_raise identifier id'>raise</span><span class='lparen token'>(</span><span class='rubyid_Errors constant id'>Errors</span><span class='colon2 op'>::</span><span class='rubyid_ValidationFailure constant id'>ValidationFailure</span><span class='comma token'>,</span> <span class='rubyid_details identifier id'>details</span><span class='rparen token'>)</span>
1504
- <span class='rubyid_end end kw'>end</span>
1505
- </pre>
1506
- </td>
1507
- </tr>
1508
- </table>
1509
- </div>
1510
-
1511
- </div>
1512
-
1513
- </div>
1514
-
1515
- <div id="footer">
1516
- Generated on Tue Mar 29 10:52:51 2016 by
1517
- <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1518
- 0.8.7.6 (ruby-2.3.0).
1519
- </div>
1520
-
1521
- </body>
1522
- </html>