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