ballast 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis-gemfile +15 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +1 -0
  6. data/CHANGELOG.md +4 -0
  7. data/Gemfile +21 -0
  8. data/README.md +40 -0
  9. data/Rakefile +28 -0
  10. data/ballast.gemspec +35 -0
  11. data/doc/Ballast/Concerns/Ajax.html +806 -0
  12. data/doc/Ballast/Concerns/Common.html +900 -0
  13. data/doc/Ballast/Concerns/ErrorsHandling.html +283 -0
  14. data/doc/Ballast/Concerns/View.html +664 -0
  15. data/doc/Ballast/Concerns.html +127 -0
  16. data/doc/Ballast/Context.html +417 -0
  17. data/doc/Ballast/Errors/BaseError.html +326 -0
  18. data/doc/Ballast/Errors/InvalidDomain.html +157 -0
  19. data/doc/Ballast/Errors/PerformError.html +157 -0
  20. data/doc/Ballast/Errors/ValidationError.html +157 -0
  21. data/doc/Ballast/Errors.html +125 -0
  22. data/doc/Ballast/Operation.html +1304 -0
  23. data/doc/Ballast/OperationsChain.html +585 -0
  24. data/doc/Ballast/Version.html +189 -0
  25. data/doc/Ballast.html +130 -0
  26. data/doc/_index.html +267 -0
  27. data/doc/class_list.html +54 -0
  28. data/doc/css/common.css +1 -0
  29. data/doc/css/full_list.css +57 -0
  30. data/doc/css/style.css +338 -0
  31. data/doc/file.README.html +115 -0
  32. data/doc/file_list.html +56 -0
  33. data/doc/frames.html +26 -0
  34. data/doc/index.html +115 -0
  35. data/doc/js/app.js +219 -0
  36. data/doc/js/full_list.js +178 -0
  37. data/doc/js/jquery.js +4 -0
  38. data/doc/method_list.html +269 -0
  39. data/doc/top-level-namespace.html +112 -0
  40. data/lib/ballast/concerns/ajax.rb +116 -0
  41. data/lib/ballast/concerns/common.rb +97 -0
  42. data/lib/ballast/concerns/errors_handling.rb +49 -0
  43. data/lib/ballast/concerns/view.rb +63 -0
  44. data/lib/ballast/context.rb +38 -0
  45. data/lib/ballast/errors.rb +34 -0
  46. data/lib/ballast/operation.rb +136 -0
  47. data/lib/ballast/operations_chain.rb +38 -0
  48. data/lib/ballast/version.rb +24 -0
  49. data/lib/ballast.rb +24 -0
  50. data/spec/ballast/concerns/ajax_spec.rb +124 -0
  51. data/spec/ballast/concerns/common_spec.rb +100 -0
  52. data/spec/ballast/concerns/errors_handling_spec.rb +63 -0
  53. data/spec/ballast/concerns/view_spec.rb +107 -0
  54. data/spec/ballast/context_spec.rb +23 -0
  55. data/spec/ballast/errors_spec.rb +16 -0
  56. data/spec/ballast/operation_spec.rb +175 -0
  57. data/spec/ballast/operations_chain_spec.rb +33 -0
  58. data/spec/coverage_helper.rb +19 -0
  59. data/spec/spec_helper.rb +19 -0
  60. metadata +225 -0
@@ -0,0 +1,1304 @@
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::Operation
8
+
9
+ &mdash; Documentation by YARD 0.8.7.3
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#!" + escape(window.location.href);
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 (O)</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">Operation</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::Operation
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::Operation</li>
82
+
83
+ </ul>
84
+ <a href="#" class="inheritanceTree">show all</a>
85
+
86
+ </dd>
87
+
88
+
89
+
90
+
91
+ <dt class="r2">Extended by:</dt>
92
+ <dd class="r2">Forwardable</dd>
93
+
94
+
95
+
96
+
97
+ <dt class="r1">Includes:</dt>
98
+ <dd class="r1">Interactor</dd>
99
+
100
+
101
+
102
+
103
+
104
+ <dt class="r2 last">Defined in:</dt>
105
+ <dd class="r2 last">lib/ballast/operation.rb</dd>
106
+
107
+ </dl>
108
+ <div class="clear"></div>
109
+
110
+ <h2>Overview</h2><div class="docstring">
111
+ <div class="discussion">
112
+ <p>A operation represents a single responsibility class. Subclasses should only expose and override the #perform method.</p>
113
+
114
+
115
+ </div>
116
+ </div>
117
+ <div class="tags">
118
+
119
+
120
+ </div><div id="subclasses">
121
+ <h2>Direct Known Subclasses</h2>
122
+ <p class="children"><span class='object_link'><a href="OperationsChain.html" title="Ballast::OperationsChain (class)">OperationsChain</a></span></p>
123
+ </div>
124
+
125
+
126
+
127
+
128
+
129
+
130
+
131
+
132
+ <h2>
133
+ Class Method Summary
134
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
135
+ </h2>
136
+
137
+ <ul class="summary">
138
+
139
+ <li class="public ">
140
+ <span class="summary_signature">
141
+
142
+ <a href="#perform-class_method" title="perform (class method)">+ (Operation) <strong>perform</strong>(owner_or_context, context: nil, params: {}) </a>
143
+
144
+
145
+
146
+ </span>
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+ <span class="summary_desc"><div class='inline'><p>Performs the operation.</p>
157
+ </div></span>
158
+
159
+ </li>
160
+
161
+
162
+ </ul>
163
+
164
+ <h2>
165
+ Instance Method Summary
166
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
167
+ </h2>
168
+
169
+ <ul class="summary">
170
+
171
+ <li class="public ">
172
+ <span class="summary_signature">
173
+
174
+ <a href="#fail%21-instance_method" title="#fail! (instance method)">- (Object) <strong>fail!</strong>(error = nil) </a>
175
+
176
+
177
+
178
+ </span>
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+ <span class="summary_desc"><div class='inline'><p>Marks failure of the operation appending the error to the context.</p>
189
+ </div></span>
190
+
191
+ </li>
192
+
193
+
194
+ <li class="public ">
195
+ <span class="summary_signature">
196
+
197
+ <a href="#import_error-instance_method" title="#import_error (instance method)">- (Object) <strong>import_error</strong>(target, to_flash = true, first_only = true) </a>
198
+
199
+
200
+
201
+ </span>
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ <span class="summary_desc"><div class='inline'><p>Imports the current operation errors into the target’s <code>@error</code> instance variable or in the flash hash.</p>
212
+ </div></span>
213
+
214
+ </li>
215
+
216
+
217
+ <li class="public ">
218
+ <span class="summary_signature">
219
+
220
+ <a href="#import_response-instance_method" title="#import_response (instance method)">- (Object) <strong>import_response</strong>(target, overwrite: true, *fields) </a>
221
+
222
+
223
+
224
+ </span>
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ <span class="summary_desc"><div class='inline'><p>Imports the response hash into the target instance variables.</p>
235
+ </div></span>
236
+
237
+ </li>
238
+
239
+
240
+ <li class="public ">
241
+ <span class="summary_signature">
242
+
243
+ <a href="#in_em_thread-instance_method" title="#in_em_thread (instance method)">- (Object) <strong>in_em_thread</strong>(&amp;block) </a>
244
+
245
+
246
+
247
+ </span>
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+
257
+ <span class="summary_desc"><div class='inline'><p>If running under eventmachine, run the block in a thread of its threadpool using EM::Synchrony, otherwise run the block normally.</p>
258
+ </div></span>
259
+
260
+ </li>
261
+
262
+
263
+ <li class="public ">
264
+ <span class="summary_signature">
265
+
266
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Operation) <strong>initialize</strong>(context) </a>
267
+
268
+
269
+
270
+ </span>
271
+
272
+
273
+ <span class="note title constructor">constructor</span>
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+ <span class="summary_desc"><div class='inline'><p>Creates a new operation.</p>
283
+ </div></span>
284
+
285
+ </li>
286
+
287
+
288
+ <li class="public ">
289
+ <span class="summary_signature">
290
+
291
+ <a href="#method_missing-instance_method" title="#method_missing (instance method)">- (Object) <strong>method_missing</strong>(method, *args, &amp;block) </a>
292
+
293
+
294
+
295
+ </span>
296
+
297
+
298
+
299
+
300
+
301
+
302
+
303
+
304
+
305
+ <span class="summary_desc"><div class='inline'><p>Forwards any missing method to the owner.</p>
306
+ </div></span>
307
+
308
+ </li>
309
+
310
+
311
+ <li class="public ">
312
+ <span class="summary_signature">
313
+
314
+ <a href="#perform_with_handling-instance_method" title="#perform_with_handling (instance method)">- (Object) <strong>perform_with_handling</strong>(setup_response_after = true) </a>
315
+
316
+
317
+
318
+ </span>
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+ <span class="summary_desc"><div class='inline'><p>Performs the operation handling base errors.</p>
329
+ </div></span>
330
+
331
+ </li>
332
+
333
+
334
+ <li class="public ">
335
+ <span class="summary_signature">
336
+
337
+ <a href="#resolve_error-instance_method" title="#resolve_error (instance method)">- (String|Hash) <strong>resolve_error</strong>(error, supported_messages = {}, only_message = false) </a>
338
+
339
+
340
+
341
+ </span>
342
+
343
+
344
+
345
+
346
+
347
+
348
+
349
+
350
+
351
+ <span class="summary_desc"><div class='inline'><p>Resolves a numeric error to a human readable message.</p>
352
+ </div></span>
353
+
354
+ </li>
355
+
356
+
357
+ <li class="public ">
358
+ <span class="summary_signature">
359
+
360
+ <a href="#setup_response-instance_method" title="#setup_response (instance method)">- (Hash) <strong>setup_response</strong>(force = false) </a>
361
+
362
+
363
+
364
+ </span>
365
+
366
+
367
+
368
+
369
+
370
+
371
+
372
+
373
+
374
+ <span class="summary_desc"><div class='inline'><p>Sets up the response hash from instance variables.</p>
375
+ </div></span>
376
+
377
+ </li>
378
+
379
+
380
+ </ul>
381
+
382
+
383
+
384
+
385
+ <div id="constructor_details" class="method_details_list">
386
+ <h2>Constructor Details</h2>
387
+
388
+ <div class="method_details first">
389
+ <h3 class="signature first" id="initialize-instance_method">
390
+
391
+ - (<tt><span class='object_link'><a href="" title="Ballast::Operation (class)">Operation</a></span></tt>) <strong>initialize</strong>(context)
392
+
393
+
394
+
395
+
396
+
397
+ </h3><div class="docstring">
398
+ <div class="discussion">
399
+ <p>Creates a new operation.</p>
400
+
401
+
402
+ </div>
403
+ </div>
404
+ <div class="tags">
405
+ <p class="tag_title">Parameters:</p>
406
+ <ul class="param">
407
+
408
+ <li>
409
+
410
+ <span class='name'>context</span>
411
+
412
+
413
+ <span class='type'>(<tt><span class='object_link'><a href="Context.html" title="Ballast::Context (class)">Context</a></span></tt>)</span>
414
+
415
+
416
+
417
+ &mdash;
418
+ <div class='inline'><p>The context for the operation.</p>
419
+ </div>
420
+
421
+ </li>
422
+
423
+ </ul>
424
+
425
+
426
+ </div><table class="source_code">
427
+ <tr>
428
+ <td>
429
+ <pre class="lines">
430
+
431
+
432
+ 29
433
+ 30
434
+ 31
435
+ 32</pre>
436
+ </td>
437
+ <td>
438
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 29</span>
439
+
440
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_context'>context</span><span class='rparen'>)</span>
441
+ <span class='ivar'>@context</span> <span class='op'>=</span> <span class='id identifier rubyid_context'>context</span>
442
+ <span class='id identifier rubyid_setup'>setup</span>
443
+ <span class='kw'>end</span></pre>
444
+ </td>
445
+ </tr>
446
+ </table>
447
+ </div>
448
+
449
+ </div>
450
+ <div id="method_missing_details" class="method_details_list">
451
+ <h2>Dynamic Method Handling</h2>
452
+ <p class="notice this">
453
+ This class handles dynamic methods through the <tt>method_missing</tt> method
454
+
455
+ </p>
456
+
457
+ <div class="method_details first">
458
+ <h3 class="signature first" id="method_missing-instance_method">
459
+
460
+ - (<tt>Object</tt>) <strong>method_missing</strong>(method, *args, &amp;block)
461
+
462
+
463
+
464
+
465
+
466
+ </h3><div class="docstring">
467
+ <div class="discussion">
468
+ <p>Forwards any missing method to the owner.</p>
469
+
470
+
471
+ </div>
472
+ </div>
473
+ <div class="tags">
474
+ <p class="tag_title">Parameters:</p>
475
+ <ul class="param">
476
+
477
+ <li>
478
+
479
+ <span class='name'>method</span>
480
+
481
+
482
+ <span class='type'>(<tt>Symbol</tt>)</span>
483
+
484
+
485
+
486
+ &mdash;
487
+ <div class='inline'><p>The method to forward.</p>
488
+ </div>
489
+
490
+ </li>
491
+
492
+ <li>
493
+
494
+ <span class='name'>args</span>
495
+
496
+
497
+ <span class='type'>(<tt>Array</tt>)</span>
498
+
499
+
500
+
501
+ &mdash;
502
+ <div class='inline'><p>The arguments to pass to the method.</p>
503
+ </div>
504
+
505
+ </li>
506
+
507
+ <li>
508
+
509
+ <span class='name'>block</span>
510
+
511
+
512
+ <span class='type'>(<tt>Proc</tt>)</span>
513
+
514
+
515
+
516
+ &mdash;
517
+ <div class='inline'><p>The block to pass to the method.</p>
518
+ </div>
519
+
520
+ </li>
521
+
522
+ </ul>
523
+
524
+
525
+ </div><table class="source_code">
526
+ <tr>
527
+ <td>
528
+ <pre class="lines">
529
+
530
+
531
+ 128
532
+ 129
533
+ 130
534
+ 131
535
+ 132
536
+ 133
537
+ 134</pre>
538
+ </td>
539
+ <td>
540
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 128</span>
541
+
542
+ <span class='kw'>def</span> <span class='id identifier rubyid_method_missing'>method_missing</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
543
+ <span class='kw'>if</span> <span class='id identifier rubyid_owner'>owner</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='rparen'>)</span>
544
+ <span class='id identifier rubyid_owner'>owner</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
545
+ <span class='kw'>else</span>
546
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_method'>method</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
547
+ <span class='kw'>end</span>
548
+ <span class='kw'>end</span></pre>
549
+ </td>
550
+ </tr>
551
+ </table>
552
+ </div>
553
+
554
+ </div>
555
+
556
+
557
+ <div id="class_method_details" class="method_details_list">
558
+ <h2>Class Method Details</h2>
559
+
560
+
561
+ <div class="method_details first">
562
+ <h3 class="signature first" id="perform-class_method">
563
+
564
+ + (<tt><span class='object_link'><a href="" title="Ballast::Operation (class)">Operation</a></span></tt>) <strong>perform</strong>(owner_or_context, context: nil, params: {})
565
+
566
+
567
+
568
+
569
+
570
+ </h3><div class="docstring">
571
+ <div class="discussion">
572
+ <p>Performs the operation.</p>
573
+
574
+
575
+ </div>
576
+ </div>
577
+ <div class="tags">
578
+ <p class="tag_title">Parameters:</p>
579
+ <ul class="param">
580
+
581
+ <li>
582
+
583
+ <span class='name'>owner_or_context</span>
584
+
585
+
586
+ <span class='type'>(<tt>Object|<span class='object_link'><a href="Context.html" title="Ballast::Context (class)">Context</a></span></tt>)</span>
587
+
588
+
589
+
590
+ &mdash;
591
+ <div class='inline'><p>If is a context, then it will be the context of the operation, otherwise a blank a context with the object
592
+ as owner will be created.</p>
593
+ </div>
594
+
595
+ </li>
596
+
597
+ <li>
598
+
599
+ <span class='name'>context</span>
600
+
601
+
602
+ <span class='type'>(<tt>NilClass</tt>)</span>
603
+
604
+
605
+
606
+ &mdash;
607
+ <div class='inline'><p>The context for the operation. <em>Ignored if <code>owner_or_context</code> is a context.</em></p>
608
+ </div>
609
+
610
+ </li>
611
+
612
+ <li>
613
+
614
+ <span class='name'>params</span>
615
+
616
+
617
+ <span class='type'>(<tt>Hash</tt>)</span>
618
+
619
+
620
+
621
+ &mdash;
622
+ <div class='inline'><p>The additional parameters for the new context. <em>Ignored if <code>owner_or_context</code> is a context.</em></p>
623
+ </div>
624
+
625
+ </li>
626
+
627
+ </ul>
628
+
629
+ <p class="tag_title">Returns:</p>
630
+ <ul class="return">
631
+
632
+ <li>
633
+
634
+
635
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Ballast::Operation (class)">Operation</a></span></tt>)</span>
636
+
637
+
638
+
639
+ &mdash;
640
+ <div class='inline'><p>The performed operation.</p>
641
+ </div>
642
+
643
+ </li>
644
+
645
+ </ul>
646
+
647
+ </div><table class="source_code">
648
+ <tr>
649
+ <td>
650
+ <pre class="lines">
651
+
652
+
653
+ 20
654
+ 21
655
+ 22
656
+ 23
657
+ 24</pre>
658
+ </td>
659
+ <td>
660
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 20</span>
661
+
662
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_perform'>perform</span><span class='lparen'>(</span><span class='id identifier rubyid_owner_or_context'>owner_or_context</span><span class='comma'>,</span> <span class='label'>context:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='label'>params:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
663
+ <span class='id identifier rubyid_arg'>arg</span> <span class='op'>=</span> <span class='id identifier rubyid_owner_or_context'>owner_or_context</span>
664
+ <span class='id identifier rubyid_arg'>arg</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_context'>context</span> <span class='op'>||</span> <span class='op'>::</span><span class='const'>Ballast</span><span class='op'>::</span><span class='const'>Context</span><span class='period'>.</span><span class='id identifier rubyid_build'>build</span><span class='lparen'>(</span><span class='id identifier rubyid_owner_or_context'>owner_or_context</span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_arg'>arg</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Ballast</span><span class='op'>::</span><span class='const'>Context</span><span class='rparen'>)</span>
665
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='id identifier rubyid_arg'>arg</span><span class='rparen'>)</span>
666
+ <span class='kw'>end</span></pre>
667
+ </td>
668
+ </tr>
669
+ </table>
670
+ </div>
671
+
672
+ </div>
673
+
674
+ <div id="instance_method_details" class="method_details_list">
675
+ <h2>Instance Method Details</h2>
676
+
677
+
678
+ <div class="method_details first">
679
+ <h3 class="signature first" id="fail!-instance_method">
680
+
681
+ - (<tt>Object</tt>) <strong>fail!</strong>(error = nil)
682
+
683
+
684
+
685
+
686
+
687
+ </h3><div class="docstring">
688
+ <div class="discussion">
689
+ <p>Marks failure of the operation appending the error to the context.</p>
690
+
691
+
692
+ </div>
693
+ </div>
694
+ <div class="tags">
695
+ <p class="tag_title">Parameters:</p>
696
+ <ul class="param">
697
+
698
+ <li>
699
+
700
+ <span class='name'>error</span>
701
+
702
+
703
+ <span class='type'>(<tt>Object|NilClass</tt>)</span>
704
+
705
+
706
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
707
+
708
+
709
+ &mdash;
710
+ <div class='inline'><p>The error to store.</p>
711
+ </div>
712
+
713
+ </li>
714
+
715
+ </ul>
716
+
717
+
718
+ </div><table class="source_code">
719
+ <tr>
720
+ <td>
721
+ <pre class="lines">
722
+
723
+
724
+ 82
725
+ 83
726
+ 84
727
+ 85</pre>
728
+ </td>
729
+ <td>
730
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 82</span>
731
+
732
+ <span class='kw'>def</span> <span class='id identifier rubyid_fail!'>fail!</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
733
+ <span class='id identifier rubyid_errors'>errors</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_error'>error</span> <span class='kw'>if</span> <span class='id identifier rubyid_error'>error</span>
734
+ <span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
735
+ <span class='kw'>end</span></pre>
736
+ </td>
737
+ </tr>
738
+ </table>
739
+ </div>
740
+
741
+ <div class="method_details ">
742
+ <h3 class="signature " id="import_error-instance_method">
743
+
744
+ - (<tt>Object</tt>) <strong>import_error</strong>(target, to_flash = true, first_only = true)
745
+
746
+
747
+
748
+
749
+
750
+ </h3><div class="docstring">
751
+ <div class="discussion">
752
+ <p>Imports the current operation errors into the target’s <code>@error</code> instance variable or in the flash hash.</p>
753
+
754
+
755
+ </div>
756
+ </div>
757
+ <div class="tags">
758
+ <p class="tag_title">Parameters:</p>
759
+ <ul class="param">
760
+
761
+ <li>
762
+
763
+ <span class='name'>target</span>
764
+
765
+
766
+ <span class='type'>(<tt>Object</tt>)</span>
767
+
768
+
769
+
770
+ &mdash;
771
+ <div class='inline'><p>The target of the import.</p>
772
+ </div>
773
+
774
+ </li>
775
+
776
+ <li>
777
+
778
+ <span class='name'>to_flash</span>
779
+
780
+
781
+ <span class='type'>(<tt>Boolean</tt>)</span>
782
+
783
+
784
+ <em class="default">(defaults to: <tt>true</tt>)</em>
785
+
786
+
787
+ &mdash;
788
+ <div class='inline'><p>If to import the error in the target’s flash object rather than the instance variable.</p>
789
+ </div>
790
+
791
+ </li>
792
+
793
+ <li>
794
+
795
+ <span class='name'>first_only</span>
796
+
797
+
798
+ <span class='type'>(<tt>Boolean</tt>)</span>
799
+
800
+
801
+ <em class="default">(defaults to: <tt>true</tt>)</em>
802
+
803
+
804
+ &mdash;
805
+ <div class='inline'><p>If to only import the first error.</p>
806
+ </div>
807
+
808
+ </li>
809
+
810
+ </ul>
811
+
812
+
813
+ </div><table class="source_code">
814
+ <tr>
815
+ <td>
816
+ <pre class="lines">
817
+
818
+
819
+ 92
820
+ 93
821
+ 94
822
+ 95
823
+ 96
824
+ 97
825
+ 98
826
+ 99
827
+ 100
828
+ 101
829
+ 102</pre>
830
+ </td>
831
+ <td>
832
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 92</span>
833
+
834
+ <span class='kw'>def</span> <span class='id identifier rubyid_import_error'>import_error</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='id identifier rubyid_to_flash'>to_flash</span> <span class='op'>=</span> <span class='kw'>true</span><span class='comma'>,</span> <span class='id identifier rubyid_first_only'>first_only</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
835
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_errors'>errors</span>
836
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='symbol'>:error</span><span class='rbracket'>]</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_to_flash'>to_flash</span>
837
+ <span class='id identifier rubyid_values'>values</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>if</span> <span class='id identifier rubyid_first_only'>first_only</span>
838
+
839
+ <span class='kw'>if</span> <span class='id identifier rubyid_to_flash'>to_flash</span> <span class='kw'>then</span>
840
+ <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_flash'>flash</span><span class='lbracket'>[</span><span class='symbol'>:error</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_values'>values</span>
841
+ <span class='kw'>else</span>
842
+ <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='symbol'>:@error</span><span class='comma'>,</span> <span class='id identifier rubyid_values'>values</span><span class='rparen'>)</span>
843
+ <span class='kw'>end</span>
844
+ <span class='kw'>end</span></pre>
845
+ </td>
846
+ </tr>
847
+ </table>
848
+ </div>
849
+
850
+ <div class="method_details ">
851
+ <h3 class="signature " id="import_response-instance_method">
852
+
853
+ - (<tt>Object</tt>) <strong>import_response</strong>(target, overwrite: true, *fields)
854
+
855
+
856
+
857
+
858
+
859
+ </h3><div class="docstring">
860
+ <div class="discussion">
861
+ <p>Imports the response hash into the target instance variables.</p>
862
+
863
+
864
+ </div>
865
+ </div>
866
+ <div class="tags">
867
+ <p class="tag_title">Parameters:</p>
868
+ <ul class="param">
869
+
870
+ <li>
871
+
872
+ <span class='name'>target</span>
873
+
874
+
875
+ <span class='type'>(<tt>Object</tt>)</span>
876
+
877
+
878
+
879
+ &mdash;
880
+ <div class='inline'><p>The target of the import.</p>
881
+ </div>
882
+
883
+ </li>
884
+
885
+ <li>
886
+
887
+ <span class='name'>fields</span>
888
+
889
+
890
+ <span class='type'>(<tt>Array</tt>)</span>
891
+
892
+
893
+
894
+ &mdash;
895
+ <div class='inline'><p>The keys to import.</p>
896
+ </div>
897
+
898
+ </li>
899
+
900
+ <li>
901
+
902
+ <span class='name'>overwrite</span>
903
+
904
+
905
+ <span class='type'>(<tt>Boolean</tt>)</span>
906
+
907
+
908
+
909
+ &mdash;
910
+ <div class='inline'><p>Whether to overwrite existing variables into the target. If set to <code>false</code>, any overwrite will raise an <code>ArgumentError</code>.</p>
911
+ </div>
912
+
913
+ </li>
914
+
915
+ </ul>
916
+
917
+
918
+ </div><table class="source_code">
919
+ <tr>
920
+ <td>
921
+ <pre class="lines">
922
+
923
+
924
+ 57
925
+ 58
926
+ 59
927
+ 60
928
+ 61
929
+ 62</pre>
930
+ </td>
931
+ <td>
932
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 57</span>
933
+
934
+ <span class='kw'>def</span> <span class='id identifier rubyid_import_response'>import_response</span><span class='lparen'>(</span><span class='id identifier rubyid_target'>target</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_fields'>fields</span><span class='comma'>,</span> <span class='label'>overwrite:</span> <span class='kw'>true</span><span class='rparen'>)</span>
935
+ <span class='id identifier rubyid_fields'>fields</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_field'>field</span><span class='op'>|</span>
936
+ <span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_field'>field</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='op'>&amp;&amp;</span> <span class='op'>!</span><span class='id identifier rubyid_overwrite'>overwrite</span>
937
+ <span class='id identifier rubyid_target'>target</span><span class='period'>.</span><span class='id identifier rubyid_instance_variable_set'>instance_variable_set</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>@</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_field'>field</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='id identifier rubyid_response'>response</span><span class='lbracket'>[</span><span class='id identifier rubyid_field'>field</span><span class='rbracket'>]</span><span class='rparen'>)</span>
938
+ <span class='kw'>end</span>
939
+ <span class='kw'>end</span></pre>
940
+ </td>
941
+ </tr>
942
+ </table>
943
+ </div>
944
+
945
+ <div class="method_details ">
946
+ <h3 class="signature " id="in_em_thread-instance_method">
947
+
948
+ - (<tt>Object</tt>) <strong>in_em_thread</strong>(&amp;block)
949
+
950
+
951
+
952
+
953
+
954
+ </h3><div class="docstring">
955
+ <div class="discussion">
956
+ <p>If running under eventmachine, run the block in a thread of its threadpool using EM::Synchrony, otherwise run the block normally.</p>
957
+
958
+
959
+ </div>
960
+ </div>
961
+ <div class="tags">
962
+ <p class="tag_title">Parameters:</p>
963
+ <ul class="param">
964
+
965
+ <li>
966
+
967
+ <span class='name'>block</span>
968
+
969
+
970
+ <span class='type'>(<tt>Proc</tt>)</span>
971
+
972
+
973
+
974
+ &mdash;
975
+ <div class='inline'><p>The block to run.</p>
976
+ </div>
977
+
978
+ </li>
979
+
980
+ </ul>
981
+
982
+
983
+ </div><table class="source_code">
984
+ <tr>
985
+ <td>
986
+ <pre class="lines">
987
+
988
+
989
+ 119
990
+ 120
991
+ 121</pre>
992
+ </td>
993
+ <td>
994
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 119</span>
995
+
996
+ <span class='kw'>def</span> <span class='id identifier rubyid_in_em_thread'>in_em_thread</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
997
+ <span class='const'>EM</span><span class='period'>.</span><span class='id identifier rubyid_reactor_running?'>reactor_running?</span> <span class='op'>?</span> <span class='const'>EM</span><span class='op'>::</span><span class='const'>Synchrony</span><span class='period'>.</span><span class='id identifier rubyid_defer'>defer</span><span class='lparen'>(</span><span class='op'>&amp;</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
998
+ <span class='kw'>end</span></pre>
999
+ </td>
1000
+ </tr>
1001
+ </table>
1002
+ </div>
1003
+
1004
+ <div class="method_details ">
1005
+ <h3 class="signature " id="perform_with_handling-instance_method">
1006
+
1007
+ - (<tt>Object</tt>) <strong>perform_with_handling</strong>(setup_response_after = true)
1008
+
1009
+
1010
+
1011
+
1012
+
1013
+ </h3><div class="docstring">
1014
+ <div class="discussion">
1015
+ <p>Performs the operation handling base errors.</p>
1016
+
1017
+
1018
+ </div>
1019
+ </div>
1020
+ <div class="tags">
1021
+ <p class="tag_title">Parameters:</p>
1022
+ <ul class="param">
1023
+
1024
+ <li>
1025
+
1026
+ <span class='name'>setup_response_after</span>
1027
+
1028
+
1029
+ <span class='type'>(<tt>Boolean</tt>)</span>
1030
+
1031
+
1032
+ <em class="default">(defaults to: <tt>true</tt>)</em>
1033
+
1034
+
1035
+ &mdash;
1036
+ <div class='inline'><p>Whether to setup the response after processing.</p>
1037
+ </div>
1038
+
1039
+ </li>
1040
+
1041
+ </ul>
1042
+
1043
+
1044
+ </div><table class="source_code">
1045
+ <tr>
1046
+ <td>
1047
+ <pre class="lines">
1048
+
1049
+
1050
+ 67
1051
+ 68
1052
+ 69
1053
+ 70
1054
+ 71
1055
+ 72
1056
+ 73
1057
+ 74
1058
+ 75
1059
+ 76
1060
+ 77</pre>
1061
+ </td>
1062
+ <td>
1063
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 67</span>
1064
+
1065
+ <span class='kw'>def</span> <span class='id identifier rubyid_perform_with_handling'>perform_with_handling</span><span class='lparen'>(</span><span class='id identifier rubyid_setup_response_after'>setup_response_after</span> <span class='op'>=</span> <span class='kw'>true</span><span class='rparen'>)</span>
1066
+ <span class='kw'>begin</span>
1067
+ <span class='kw'>yield</span>
1068
+ <span class='kw'>rescue</span> <span class='const'>Lazier</span><span class='op'>::</span><span class='const'>Exceptions</span><span class='op'>::</span><span class='const'>Debug</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_de'>de</span>
1069
+ <span class='id identifier rubyid_raise'>raise</span> <span class='id identifier rubyid_de'>de</span>
1070
+ <span class='kw'>rescue</span> <span class='op'>=&gt;</span> <span class='id identifier rubyid_e'>e</span>
1071
+ <span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Ballast</span><span class='op'>::</span><span class='const'>Errors</span><span class='op'>::</span><span class='const'>BaseError</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_fail!'>fail!</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span>
1072
+ <span class='kw'>end</span>
1073
+
1074
+ <span class='id identifier rubyid_setup_response'>setup_response</span> <span class='kw'>if</span> <span class='id identifier rubyid_setup_response_after'>setup_response_after</span>
1075
+ <span class='kw'>end</span></pre>
1076
+ </td>
1077
+ </tr>
1078
+ </table>
1079
+ </div>
1080
+
1081
+ <div class="method_details ">
1082
+ <h3 class="signature " id="resolve_error-instance_method">
1083
+
1084
+ - (<tt>String|Hash</tt>) <strong>resolve_error</strong>(error, supported_messages = {}, only_message = false)
1085
+
1086
+
1087
+
1088
+
1089
+
1090
+ </h3><div class="docstring">
1091
+ <div class="discussion">
1092
+ <p>Resolves a numeric error to a human readable message.</p>
1093
+
1094
+
1095
+ </div>
1096
+ </div>
1097
+ <div class="tags">
1098
+ <p class="tag_title">Parameters:</p>
1099
+ <ul class="param">
1100
+
1101
+ <li>
1102
+
1103
+ <span class='name'>error</span>
1104
+
1105
+
1106
+ <span class='type'>(<tt>BaseError|Fixnum</tt>)</span>
1107
+
1108
+
1109
+
1110
+ &mdash;
1111
+ <div class='inline'><p>The error to resolve.</p>
1112
+ </div>
1113
+
1114
+ </li>
1115
+
1116
+ <li>
1117
+
1118
+ <span class='name'>supported_messages</span>
1119
+
1120
+
1121
+ <span class='type'>(<tt>Hash</tt>)</span>
1122
+
1123
+
1124
+ <em class="default">(defaults to: <tt>{}</tt>)</em>
1125
+
1126
+
1127
+ &mdash;
1128
+ <div class='inline'><p>The list of supported error codes.</p>
1129
+ </div>
1130
+
1131
+ </li>
1132
+
1133
+ <li>
1134
+
1135
+ <span class='name'>only_message</span>
1136
+
1137
+
1138
+ <span class='type'>(<tt>Boolean</tt>)</span>
1139
+
1140
+
1141
+ <em class="default">(defaults to: <tt>false</tt>)</em>
1142
+
1143
+
1144
+ &mdash;
1145
+ <div class='inline'><p>If to only return the message string rather than a full error hash.</p>
1146
+ </div>
1147
+
1148
+ </li>
1149
+
1150
+ </ul>
1151
+
1152
+ <p class="tag_title">Returns:</p>
1153
+ <ul class="return">
1154
+
1155
+ <li>
1156
+
1157
+
1158
+ <span class='type'>(<tt>String|Hash</tt>)</span>
1159
+
1160
+
1161
+
1162
+ &mdash;
1163
+ <div class='inline'><p>The error with a human readable message or the message alone.</p>
1164
+ </div>
1165
+
1166
+ </li>
1167
+
1168
+ </ul>
1169
+
1170
+ </div><table class="source_code">
1171
+ <tr>
1172
+ <td>
1173
+ <pre class="lines">
1174
+
1175
+
1176
+ 110
1177
+ 111
1178
+ 112
1179
+ 113
1180
+ 114</pre>
1181
+ </td>
1182
+ <td>
1183
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 110</span>
1184
+
1185
+ <span class='kw'>def</span> <span class='id identifier rubyid_resolve_error'>resolve_error</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='comma'>,</span> <span class='id identifier rubyid_supported_messages'>supported_messages</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='id identifier rubyid_only_message'>only_message</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
1186
+ <span class='id identifier rubyid_code'>code</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:response</span><span class='rparen'>)</span> <span class='op'>?</span> <span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span> <span class='op'>:</span> <span class='int'>500</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='lparen'>(</span><span class='int'>500</span><span class='rparen'>)</span>
1187
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>status:</span> <span class='id identifier rubyid_code'>code</span><span class='comma'>,</span> <span class='label'>error:</span> <span class='id identifier rubyid_supported_messages'>supported_messages</span><span class='period'>.</span><span class='id identifier rubyid_fetch'>fetch</span><span class='lparen'>(</span><span class='id identifier rubyid_code'>code</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Oops! We&#39;re having some issue. Please try again later.</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rbrace'>}</span>
1188
+ <span class='id identifier rubyid_only_message'>only_message</span> <span class='op'>?</span> <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='symbol'>:error</span><span class='rbracket'>]</span> <span class='op'>:</span> <span class='id identifier rubyid_rv'>rv</span>
1189
+ <span class='kw'>end</span></pre>
1190
+ </td>
1191
+ </tr>
1192
+ </table>
1193
+ </div>
1194
+
1195
+ <div class="method_details ">
1196
+ <h3 class="signature " id="setup_response-instance_method">
1197
+
1198
+ - (<tt>Hash</tt>) <strong>setup_response</strong>(force = false)
1199
+
1200
+
1201
+
1202
+
1203
+
1204
+ </h3><div class="docstring">
1205
+ <div class="discussion">
1206
+ <p>Sets up the response hash from instance variables.</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'>force</span>
1218
+
1219
+
1220
+ <span class='type'>(<tt>Boolean</tt>)</span>
1221
+
1222
+
1223
+ <em class="default">(defaults to: <tt>false</tt>)</em>
1224
+
1225
+
1226
+ &mdash;
1227
+ <div class='inline'><p>Whether to setup the response even if the operation failed.</p>
1228
+ </div>
1229
+
1230
+ </li>
1231
+
1232
+ </ul>
1233
+
1234
+ <p class="tag_title">Returns:</p>
1235
+ <ul class="return">
1236
+
1237
+ <li>
1238
+
1239
+
1240
+ <span class='type'>(<tt>Hash</tt>)</span>
1241
+
1242
+
1243
+
1244
+ &mdash;
1245
+ <div class='inline'><p>The response hash.</p>
1246
+ </div>
1247
+
1248
+ </li>
1249
+
1250
+ </ul>
1251
+
1252
+ </div><table class="source_code">
1253
+ <tr>
1254
+ <td>
1255
+ <pre class="lines">
1256
+
1257
+
1258
+ 38
1259
+ 39
1260
+ 40
1261
+ 41
1262
+ 42
1263
+ 43
1264
+ 44
1265
+ 45
1266
+ 46
1267
+ 47
1268
+ 48
1269
+ 49
1270
+ 50</pre>
1271
+ </td>
1272
+ <td>
1273
+ <pre class="code"><span class="info file"># File 'lib/ballast/operation.rb', line 38</span>
1274
+
1275
+ <span class='kw'>def</span> <span class='id identifier rubyid_setup_response'>setup_response</span><span class='lparen'>(</span><span class='id identifier rubyid_force'>force</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
1276
+ <span class='kw'>if</span> <span class='id identifier rubyid_success?'>success?</span> <span class='op'>||</span> <span class='id identifier rubyid_force'>force</span> <span class='kw'>then</span>
1277
+ <span class='id identifier rubyid_vars'>vars</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variables'>instance_variables</span>
1278
+ <span class='id identifier rubyid_vars'>vars</span><span class='period'>.</span><span class='id identifier rubyid_delete'>delete</span><span class='lparen'>(</span><span class='symbol'>:@context</span><span class='rparen'>)</span>
1279
+
1280
+ <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span><span class='period'>.</span><span class='id identifier rubyid_merge!'>merge!</span><span class='lparen'>(</span><span class='id identifier rubyid_vars'>vars</span><span class='period'>.</span><span class='id identifier rubyid_reduce'>reduce</span><span class='lparen'>(</span><span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span><span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_var'>var</span><span class='op'>|</span>
1281
+ <span class='id identifier rubyid_rv'>rv</span><span class='lbracket'>[</span><span class='id identifier rubyid_var'>var</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_gsub'>gsub</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>[:@]</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_instance_variable_get'>instance_variable_get</span><span class='lparen'>(</span><span class='id identifier rubyid_var'>var</span><span class='rparen'>)</span>
1282
+ <span class='id identifier rubyid_rv'>rv</span>
1283
+ <span class='rbrace'>}</span><span class='rparen'>)</span>
1284
+ <span class='kw'>end</span>
1285
+
1286
+ <span class='id identifier rubyid_context'>context</span><span class='period'>.</span><span class='id identifier rubyid_response'>response</span>
1287
+ <span class='kw'>end</span></pre>
1288
+ </td>
1289
+ </tr>
1290
+ </table>
1291
+ </div>
1292
+
1293
+ </div>
1294
+
1295
+ </div>
1296
+
1297
+ <div id="footer">
1298
+ Generated on Wed Dec 25 11:35:23 2013 by
1299
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1300
+ 0.8.7.3 (ruby-2.0.0).
1301
+ </div>
1302
+
1303
+ </body>
1304
+ </html>