ballast 1.9.3 → 2.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +35 -0
- data/.travis-gemfile +4 -5
- data/.travis.yml +3 -2
- data/CHANGELOG.md +62 -6
- data/Gemfile +7 -8
- data/README.md +2 -2
- data/ballast.gemspec +9 -12
- data/doc/Ballast/AjaxResponse.html +1380 -0
- data/doc/Ballast/Concerns/AjaxHandling.html +662 -0
- data/doc/Ballast/Concerns/Common.html +81 -361
- data/doc/Ballast/Concerns/ErrorsHandling.html +18 -36
- data/doc/Ballast/Concerns/View.html +181 -157
- data/doc/Ballast/Concerns.html +6 -6
- data/doc/Ballast/Configuration.html +204 -31
- data/doc/Ballast/Emoji/Character.html +411 -0
- data/doc/Ballast/Emoji/Utils.html +794 -0
- data/doc/Ballast/Emoji.html +125 -0
- data/doc/Ballast/Errors/{BaseError.html → Base.html} +61 -34
- data/doc/Ballast/Errors/{PerformError.html → Failure.html} +21 -17
- data/doc/Ballast/Errors/InvalidDomain.html +11 -11
- data/doc/Ballast/Errors/{ValidationError.html → ValidationFailure.html} +24 -16
- data/doc/Ballast/Errors.html +5 -5
- data/doc/Ballast/Middlewares/DefaultHost.html +6 -6
- data/doc/Ballast/Middlewares.html +4 -4
- data/doc/Ballast/RequestDomainMatcher.html +28 -28
- data/doc/Ballast/Service/Response.html +1243 -0
- data/doc/Ballast/Service.html +1314 -0
- data/doc/Ballast/Version.html +7 -7
- data/doc/Ballast.html +15 -15
- data/doc/_index.html +59 -30
- data/doc/class_list.html +6 -2
- data/doc/css/style.css +1 -0
- data/doc/file.README.html +6 -6
- data/doc/file_list.html +5 -1
- data/doc/frames.html +1 -1
- data/doc/index.html +6 -6
- data/doc/js/full_list.js +4 -1
- data/doc/method_list.html +167 -79
- data/doc/top-level-namespace.html +41 -4
- data/lib/ballast/ajax_response.rb +76 -0
- data/lib/ballast/concerns/ajax_handling.rb +73 -0
- data/lib/ballast/concerns/common.rb +25 -47
- data/lib/ballast/concerns/errors_handling.rb +21 -30
- data/lib/ballast/concerns/view.rb +24 -22
- data/lib/ballast/configuration.rb +30 -10
- data/lib/ballast/emoji.rb +114 -0
- data/lib/ballast/errors.rb +16 -13
- data/lib/ballast/middlewares/default_host.rb +3 -3
- data/lib/ballast/request_domain_matcher.rb +7 -7
- data/lib/ballast/service.rb +147 -0
- data/lib/ballast/version.rb +3 -3
- data/lib/ballast.rb +22 -22
- data/spec/ballast/ajax_response_spec.rb +61 -0
- data/spec/ballast/concerns/ajax_handling_spec.rb +86 -0
- data/spec/ballast/concerns/common_spec.rb +17 -52
- data/spec/ballast/concerns/errors_handling_spec.rb +35 -29
- data/spec/ballast/concerns/view_spec.rb +21 -32
- data/spec/ballast/configuration_spec.rb +66 -16
- data/spec/ballast/emoji_spec.rb +103 -0
- data/spec/ballast/errors_spec.rb +5 -5
- data/spec/ballast/middlewares/default_host_spec.rb +3 -5
- data/spec/ballast/request_domain_matcher_spec.rb +4 -4
- data/spec/ballast/service_spec.rb +137 -0
- data/spec/spec_helper.rb +1 -13
- metadata +42 -80
- data/doc/Ballast/Concerns/Ajax.html +0 -945
- data/doc/Ballast/Context.html +0 -417
- data/doc/Ballast/Operation.html +0 -1304
- data/doc/Ballast/OperationsChain.html +0 -597
- data/lib/ballast/concerns/ajax.rb +0 -134
- data/lib/ballast/context.rb +0 -38
- data/lib/ballast/operation.rb +0 -136
- data/lib/ballast/operations_chain.rb +0 -45
- data/spec/ballast/concerns/ajax_spec.rb +0 -141
- data/spec/ballast/context_spec.rb +0 -23
- data/spec/ballast/operation_spec.rb +0 -177
- data/spec/ballast/operations_chain_spec.rb +0 -61
@@ -0,0 +1,1243 @@
|
|
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::Response
|
8
|
+
|
9
|
+
— 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/Response.html";
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="../../_index.html">Index (R)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Ballast.html" title="Ballast (module)">Ballast</a></span></span> » <span class='title'><span class='object_link'><a href="../Service.html" title="Ballast::Service (class)">Service</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Response</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::Response
|
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::Response</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 response to a service invocation.</p>
|
105
|
+
|
106
|
+
|
107
|
+
</div>
|
108
|
+
</div>
|
109
|
+
<div class="tags">
|
110
|
+
|
111
|
+
|
112
|
+
</div>
|
113
|
+
|
114
|
+
|
115
|
+
|
116
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
117
|
+
<ul class="summary">
|
118
|
+
|
119
|
+
<li class="public ">
|
120
|
+
<span class="summary_signature">
|
121
|
+
|
122
|
+
<a href="#data-instance_method" title="#data (instance method)">- (Object) <strong>data</strong> </a>
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
</span>
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<span class="note title readonly">readonly</span>
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<span class="summary_desc"><div class='inline'><p>The data returned by the operation.</p>
|
142
|
+
</div></span>
|
143
|
+
|
144
|
+
</li>
|
145
|
+
|
146
|
+
|
147
|
+
<li class="public ">
|
148
|
+
<span class="summary_signature">
|
149
|
+
|
150
|
+
<a href="#errors-instance_method" title="#errors (instance method)">- (Array) <strong>errors</strong> </a>
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
</span>
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
<span class="note title readonly">readonly</span>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
<span class="summary_desc"><div class='inline'><p>The errors returned by the operation.</p>
|
170
|
+
</div></span>
|
171
|
+
|
172
|
+
</li>
|
173
|
+
|
174
|
+
|
175
|
+
<li class="public ">
|
176
|
+
<span class="summary_signature">
|
177
|
+
|
178
|
+
<a href="#success-instance_method" title="#success (instance method)">- (Boolean) <strong>success</strong> </a>
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
</span>
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
<span class="note title readonly">readonly</span>
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
<span class="summary_desc"><div class='inline'><p>Whether the invocation was successful or not.</p>
|
198
|
+
</div></span>
|
199
|
+
|
200
|
+
</li>
|
201
|
+
|
202
|
+
|
203
|
+
</ul>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
<h2>
|
210
|
+
Instance Method Summary
|
211
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
212
|
+
</h2>
|
213
|
+
|
214
|
+
<ul class="summary">
|
215
|
+
|
216
|
+
<li class="public ">
|
217
|
+
<span class="summary_signature">
|
218
|
+
|
219
|
+
<a href="#as_ajax_response-instance_method" title="#as_ajax_response (instance method)">- (AjaxResponse) <strong>as_ajax_response</strong> </a>
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
</span>
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
<span class="summary_desc"><div class='inline'><p>Converts this response to a AJAX response.</p>
|
234
|
+
</div></span>
|
235
|
+
|
236
|
+
</li>
|
237
|
+
|
238
|
+
|
239
|
+
<li class="public ">
|
240
|
+
<span class="summary_signature">
|
241
|
+
|
242
|
+
<a href="#error-instance_method" title="#error (instance method)">- (Object) <strong>error</strong> </a>
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
</span>
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
<span class="summary_desc"><div class='inline'><p>Returns the first error returned by the operation.</p>
|
257
|
+
</div></span>
|
258
|
+
|
259
|
+
</li>
|
260
|
+
|
261
|
+
|
262
|
+
<li class="public ">
|
263
|
+
<span class="summary_signature">
|
264
|
+
|
265
|
+
<a href="#fail%3F-instance_method" title="#fail? (instance method)">- (Boolean) <strong>fail?</strong> </a>
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
(also: #failed?)
|
270
|
+
|
271
|
+
</span>
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
<span class="summary_desc"><div class='inline'><p>Returns whether the invocation failed or not.</p>
|
282
|
+
</div></span>
|
283
|
+
|
284
|
+
</li>
|
285
|
+
|
286
|
+
|
287
|
+
<li class="public ">
|
288
|
+
<span class="summary_signature">
|
289
|
+
|
290
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Response) <strong>initialize</strong>(success = true, data: nil, errors: nil, error: nil) </a>
|
291
|
+
|
292
|
+
|
293
|
+
|
294
|
+
</span>
|
295
|
+
|
296
|
+
|
297
|
+
<span class="note title constructor">constructor</span>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
<span class="summary_desc"><div class='inline'><p>Creates a new service response.</p>
|
307
|
+
</div></span>
|
308
|
+
|
309
|
+
</li>
|
310
|
+
|
311
|
+
|
312
|
+
<li class="public ">
|
313
|
+
<span class="summary_signature">
|
314
|
+
|
315
|
+
<a href="#success%3F-instance_method" title="#success? (instance method)">- (Boolean) <strong>success?</strong> </a>
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
(also: #successful?, #succeeded?)
|
320
|
+
|
321
|
+
</span>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<span class="summary_desc"><div class='inline'><p>Returns whether the invocation was successful or not.</p>
|
332
|
+
</div></span>
|
333
|
+
|
334
|
+
</li>
|
335
|
+
|
336
|
+
|
337
|
+
</ul>
|
338
|
+
|
339
|
+
|
340
|
+
<div id="constructor_details" class="method_details_list">
|
341
|
+
<h2>Constructor Details</h2>
|
342
|
+
|
343
|
+
<div class="method_details first">
|
344
|
+
<h3 class="signature first" id="initialize-instance_method">
|
345
|
+
|
346
|
+
- (<tt><span class='object_link'><a href="" title="Ballast::Service::Response (class)">Response</a></span></tt>) <strong>initialize</strong>(success = true, data: nil, errors: nil, error: nil)
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
</h3><div class="docstring">
|
353
|
+
<div class="discussion">
|
354
|
+
<p>Creates a new service response.</p>
|
355
|
+
|
356
|
+
|
357
|
+
</div>
|
358
|
+
</div>
|
359
|
+
<div class="tags">
|
360
|
+
<p class="tag_title">Parameters:</p>
|
361
|
+
<ul class="param">
|
362
|
+
|
363
|
+
<li>
|
364
|
+
|
365
|
+
<span class='name'>success</span>
|
366
|
+
|
367
|
+
|
368
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
369
|
+
|
370
|
+
|
371
|
+
<em class="default">(defaults to: <tt>true</tt>)</em>
|
372
|
+
|
373
|
+
|
374
|
+
—
|
375
|
+
<div class='inline'><p>Whether the invocation was successful or not.</p>
|
376
|
+
</div>
|
377
|
+
|
378
|
+
</li>
|
379
|
+
|
380
|
+
<li>
|
381
|
+
|
382
|
+
<span class='name'>data</span>
|
383
|
+
|
384
|
+
|
385
|
+
<span class='type'>(<tt>Object|NilClass</tt>)</span>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
—
|
390
|
+
<div class='inline'><p>The data returned by the operation.</p>
|
391
|
+
</div>
|
392
|
+
|
393
|
+
</li>
|
394
|
+
|
395
|
+
<li>
|
396
|
+
|
397
|
+
<span class='name'>errors</span>
|
398
|
+
|
399
|
+
|
400
|
+
<span class='type'>(<tt>Array|NilClass</tt>)</span>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
—
|
405
|
+
<div class='inline'><p>The errors returned by the operation.</p>
|
406
|
+
</div>
|
407
|
+
|
408
|
+
</li>
|
409
|
+
|
410
|
+
<li>
|
411
|
+
|
412
|
+
<span class='name'>error</span>
|
413
|
+
|
414
|
+
|
415
|
+
<span class='type'>(<tt>Object|NilClass</tt>)</span>
|
416
|
+
|
417
|
+
|
418
|
+
|
419
|
+
—
|
420
|
+
<div class='inline'><p>Alias for errors. <em>Ignored if <code>errors</code> is present.</em></p>
|
421
|
+
</div>
|
422
|
+
|
423
|
+
</li>
|
424
|
+
|
425
|
+
</ul>
|
426
|
+
|
427
|
+
|
428
|
+
</div><table class="source_code">
|
429
|
+
<tr>
|
430
|
+
<td>
|
431
|
+
<pre class="lines">
|
432
|
+
|
433
|
+
|
434
|
+
29
|
435
|
+
30
|
436
|
+
31
|
437
|
+
32
|
438
|
+
33
|
439
|
+
34
|
440
|
+
35</pre>
|
441
|
+
</td>
|
442
|
+
<td>
|
443
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 29</span>
|
444
|
+
|
445
|
+
<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>
|
446
|
+
<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>
|
447
|
+
|
448
|
+
<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>
|
449
|
+
<span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
|
450
|
+
<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>
|
451
|
+
<span class='kw'>end</span></pre>
|
452
|
+
</td>
|
453
|
+
</tr>
|
454
|
+
</table>
|
455
|
+
</div>
|
456
|
+
|
457
|
+
</div>
|
458
|
+
|
459
|
+
<div id="instance_attr_details" class="attr_details">
|
460
|
+
<h2>Instance Attribute Details</h2>
|
461
|
+
|
462
|
+
|
463
|
+
<span id=""></span>
|
464
|
+
<div class="method_details first">
|
465
|
+
<h3 class="signature first" id="data-instance_method">
|
466
|
+
|
467
|
+
- (<tt>Object</tt>) <strong>data</strong> <span class="extras">(readonly)</span>
|
468
|
+
|
469
|
+
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
</h3><div class="docstring">
|
474
|
+
<div class="discussion">
|
475
|
+
<p>Returns The data returned by the operation.</p>
|
476
|
+
|
477
|
+
|
478
|
+
</div>
|
479
|
+
</div>
|
480
|
+
<div class="tags">
|
481
|
+
|
482
|
+
<p class="tag_title">Returns:</p>
|
483
|
+
<ul class="return">
|
484
|
+
|
485
|
+
<li>
|
486
|
+
|
487
|
+
|
488
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
—
|
493
|
+
<div class='inline'><p>The data returned by the operation.</p>
|
494
|
+
</div>
|
495
|
+
|
496
|
+
</li>
|
497
|
+
|
498
|
+
</ul>
|
499
|
+
|
500
|
+
</div><table class="source_code">
|
501
|
+
<tr>
|
502
|
+
<td>
|
503
|
+
<pre class="lines">
|
504
|
+
|
505
|
+
|
506
|
+
20
|
507
|
+
21
|
508
|
+
22
|
509
|
+
23
|
510
|
+
24
|
511
|
+
25
|
512
|
+
26
|
513
|
+
27
|
514
|
+
28
|
515
|
+
29
|
516
|
+
30
|
517
|
+
31
|
518
|
+
32
|
519
|
+
33
|
520
|
+
34
|
521
|
+
35
|
522
|
+
36
|
523
|
+
37
|
524
|
+
38
|
525
|
+
39
|
526
|
+
40
|
527
|
+
41
|
528
|
+
42
|
529
|
+
43
|
530
|
+
44
|
531
|
+
45
|
532
|
+
46
|
533
|
+
47
|
534
|
+
48
|
535
|
+
49
|
536
|
+
50
|
537
|
+
51
|
538
|
+
52
|
539
|
+
53
|
540
|
+
54
|
541
|
+
55
|
542
|
+
56
|
543
|
+
57
|
544
|
+
58
|
545
|
+
59
|
546
|
+
60
|
547
|
+
61
|
548
|
+
62
|
549
|
+
63
|
550
|
+
64
|
551
|
+
65
|
552
|
+
66
|
553
|
+
67
|
554
|
+
68
|
555
|
+
69
|
556
|
+
70
|
557
|
+
71
|
558
|
+
72
|
559
|
+
73
|
560
|
+
74
|
561
|
+
75
|
562
|
+
76
|
563
|
+
77</pre>
|
564
|
+
</td>
|
565
|
+
<td>
|
566
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 20</span>
|
567
|
+
|
568
|
+
<span class='kw'>class</span> <span class='const'>Response</span>
|
569
|
+
<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>
|
570
|
+
|
571
|
+
<span class='comment'># Creates a new service response.
|
572
|
+
</span> <span class='comment'>#
|
573
|
+
</span> <span class='comment'># @param success [Boolean] Whether the invocation was successful or not.
|
574
|
+
</span> <span class='comment'># @param data [Object|NilClass] The data returned by the operation.
|
575
|
+
</span> <span class='comment'># @param errors [Array|NilClass] The errors returned by the operation.
|
576
|
+
</span> <span class='comment'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*
|
577
|
+
</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>
|
578
|
+
<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>
|
579
|
+
|
580
|
+
<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>
|
581
|
+
<span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
|
582
|
+
<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>
|
583
|
+
<span class='kw'>end</span>
|
584
|
+
|
585
|
+
<span class='comment'># Returns whether the invocation was successful or not.
|
586
|
+
</span> <span class='comment'>#
|
587
|
+
</span> <span class='comment'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.
|
588
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_success?'>success?</span>
|
589
|
+
<span class='comment'># TODO@PI: Ignore rubocop on this
|
590
|
+
</span> <span class='ivar'>@success</span>
|
591
|
+
<span class='kw'>end</span>
|
592
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:successful?</span><span class='comma'>,</span> <span class='symbol'>:success?</span>
|
593
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:succeeded?</span><span class='comma'>,</span> <span class='symbol'>:success?</span>
|
594
|
+
|
595
|
+
<span class='comment'># Returns whether the invocation failed or not.
|
596
|
+
</span> <span class='comment'>#
|
597
|
+
</span> <span class='comment'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.
|
598
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fail?'>fail?</span>
|
599
|
+
<span class='op'>!</span><span class='ivar'>@success</span>
|
600
|
+
<span class='kw'>end</span>
|
601
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:failed?</span><span class='comma'>,</span> <span class='symbol'>:fail?</span>
|
602
|
+
|
603
|
+
<span class='comment'># Returns the first error returned by the operation.
|
604
|
+
</span> <span class='comment'>#
|
605
|
+
</span> <span class='comment'># @return [Object] The first error returned by the service.
|
606
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_error'>error</span>
|
607
|
+
<span class='ivar'>@errors</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
608
|
+
<span class='kw'>end</span>
|
609
|
+
|
610
|
+
<span class='comment'># Converts this response to a AJAX response.
|
611
|
+
</span> <span class='comment'>#
|
612
|
+
</span> <span class='comment'># @return [AjaxResponse] The AJAX response, which will include only the first error.
|
613
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_as_ajax_response'>as_ajax_response</span>
|
614
|
+
<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>
|
615
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_successful?'>successful?</span>
|
616
|
+
<span class='lbracket'>[</span><span class='symbol'>:ok</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rbracket'>]</span>
|
617
|
+
<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>
|
618
|
+
<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>
|
619
|
+
<span class='kw'>else</span>
|
620
|
+
<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>
|
621
|
+
<span class='kw'>end</span>
|
622
|
+
|
623
|
+
<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='rparen'>)</span>
|
624
|
+
<span class='kw'>end</span>
|
625
|
+
<span class='kw'>end</span></pre>
|
626
|
+
</td>
|
627
|
+
</tr>
|
628
|
+
</table>
|
629
|
+
</div>
|
630
|
+
|
631
|
+
|
632
|
+
<span id=""></span>
|
633
|
+
<div class="method_details ">
|
634
|
+
<h3 class="signature " id="errors-instance_method">
|
635
|
+
|
636
|
+
- (<tt>Array</tt>) <strong>errors</strong> <span class="extras">(readonly)</span>
|
637
|
+
|
638
|
+
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
</h3><div class="docstring">
|
643
|
+
<div class="discussion">
|
644
|
+
<p>Returns The errors returned by the operation.</p>
|
645
|
+
|
646
|
+
|
647
|
+
</div>
|
648
|
+
</div>
|
649
|
+
<div class="tags">
|
650
|
+
|
651
|
+
<p class="tag_title">Returns:</p>
|
652
|
+
<ul class="return">
|
653
|
+
|
654
|
+
<li>
|
655
|
+
|
656
|
+
|
657
|
+
<span class='type'>(<tt>Array</tt>)</span>
|
658
|
+
|
659
|
+
|
660
|
+
|
661
|
+
—
|
662
|
+
<div class='inline'><p>The errors returned by the operation.</p>
|
663
|
+
</div>
|
664
|
+
|
665
|
+
</li>
|
666
|
+
|
667
|
+
</ul>
|
668
|
+
|
669
|
+
</div><table class="source_code">
|
670
|
+
<tr>
|
671
|
+
<td>
|
672
|
+
<pre class="lines">
|
673
|
+
|
674
|
+
|
675
|
+
20
|
676
|
+
21
|
677
|
+
22
|
678
|
+
23
|
679
|
+
24
|
680
|
+
25
|
681
|
+
26
|
682
|
+
27
|
683
|
+
28
|
684
|
+
29
|
685
|
+
30
|
686
|
+
31
|
687
|
+
32
|
688
|
+
33
|
689
|
+
34
|
690
|
+
35
|
691
|
+
36
|
692
|
+
37
|
693
|
+
38
|
694
|
+
39
|
695
|
+
40
|
696
|
+
41
|
697
|
+
42
|
698
|
+
43
|
699
|
+
44
|
700
|
+
45
|
701
|
+
46
|
702
|
+
47
|
703
|
+
48
|
704
|
+
49
|
705
|
+
50
|
706
|
+
51
|
707
|
+
52
|
708
|
+
53
|
709
|
+
54
|
710
|
+
55
|
711
|
+
56
|
712
|
+
57
|
713
|
+
58
|
714
|
+
59
|
715
|
+
60
|
716
|
+
61
|
717
|
+
62
|
718
|
+
63
|
719
|
+
64
|
720
|
+
65
|
721
|
+
66
|
722
|
+
67
|
723
|
+
68
|
724
|
+
69
|
725
|
+
70
|
726
|
+
71
|
727
|
+
72
|
728
|
+
73
|
729
|
+
74
|
730
|
+
75
|
731
|
+
76
|
732
|
+
77</pre>
|
733
|
+
</td>
|
734
|
+
<td>
|
735
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 20</span>
|
736
|
+
|
737
|
+
<span class='kw'>class</span> <span class='const'>Response</span>
|
738
|
+
<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>
|
739
|
+
|
740
|
+
<span class='comment'># Creates a new service response.
|
741
|
+
</span> <span class='comment'>#
|
742
|
+
</span> <span class='comment'># @param success [Boolean] Whether the invocation was successful or not.
|
743
|
+
</span> <span class='comment'># @param data [Object|NilClass] The data returned by the operation.
|
744
|
+
</span> <span class='comment'># @param errors [Array|NilClass] The errors returned by the operation.
|
745
|
+
</span> <span class='comment'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*
|
746
|
+
</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>
|
747
|
+
<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>
|
748
|
+
|
749
|
+
<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>
|
750
|
+
<span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
|
751
|
+
<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>
|
752
|
+
<span class='kw'>end</span>
|
753
|
+
|
754
|
+
<span class='comment'># Returns whether the invocation was successful or not.
|
755
|
+
</span> <span class='comment'>#
|
756
|
+
</span> <span class='comment'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.
|
757
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_success?'>success?</span>
|
758
|
+
<span class='comment'># TODO@PI: Ignore rubocop on this
|
759
|
+
</span> <span class='ivar'>@success</span>
|
760
|
+
<span class='kw'>end</span>
|
761
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:successful?</span><span class='comma'>,</span> <span class='symbol'>:success?</span>
|
762
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:succeeded?</span><span class='comma'>,</span> <span class='symbol'>:success?</span>
|
763
|
+
|
764
|
+
<span class='comment'># Returns whether the invocation failed or not.
|
765
|
+
</span> <span class='comment'>#
|
766
|
+
</span> <span class='comment'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.
|
767
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fail?'>fail?</span>
|
768
|
+
<span class='op'>!</span><span class='ivar'>@success</span>
|
769
|
+
<span class='kw'>end</span>
|
770
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:failed?</span><span class='comma'>,</span> <span class='symbol'>:fail?</span>
|
771
|
+
|
772
|
+
<span class='comment'># Returns the first error returned by the operation.
|
773
|
+
</span> <span class='comment'>#
|
774
|
+
</span> <span class='comment'># @return [Object] The first error returned by the service.
|
775
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_error'>error</span>
|
776
|
+
<span class='ivar'>@errors</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
777
|
+
<span class='kw'>end</span>
|
778
|
+
|
779
|
+
<span class='comment'># Converts this response to a AJAX response.
|
780
|
+
</span> <span class='comment'>#
|
781
|
+
</span> <span class='comment'># @return [AjaxResponse] The AJAX response, which will include only the first error.
|
782
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_as_ajax_response'>as_ajax_response</span>
|
783
|
+
<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>
|
784
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_successful?'>successful?</span>
|
785
|
+
<span class='lbracket'>[</span><span class='symbol'>:ok</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rbracket'>]</span>
|
786
|
+
<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>
|
787
|
+
<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>
|
788
|
+
<span class='kw'>else</span>
|
789
|
+
<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>
|
790
|
+
<span class='kw'>end</span>
|
791
|
+
|
792
|
+
<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='rparen'>)</span>
|
793
|
+
<span class='kw'>end</span>
|
794
|
+
<span class='kw'>end</span></pre>
|
795
|
+
</td>
|
796
|
+
</tr>
|
797
|
+
</table>
|
798
|
+
</div>
|
799
|
+
|
800
|
+
|
801
|
+
<span id=""></span>
|
802
|
+
<div class="method_details ">
|
803
|
+
<h3 class="signature " id="success-instance_method">
|
804
|
+
|
805
|
+
- (<tt>Boolean</tt>) <strong>success</strong> <span class="extras">(readonly)</span>
|
806
|
+
|
807
|
+
|
808
|
+
|
809
|
+
|
810
|
+
|
811
|
+
</h3><div class="docstring">
|
812
|
+
<div class="discussion">
|
813
|
+
<p>Returns Whether the invocation was successful or not.</p>
|
814
|
+
|
815
|
+
|
816
|
+
</div>
|
817
|
+
</div>
|
818
|
+
<div class="tags">
|
819
|
+
|
820
|
+
<p class="tag_title">Returns:</p>
|
821
|
+
<ul class="return">
|
822
|
+
|
823
|
+
<li>
|
824
|
+
|
825
|
+
|
826
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
—
|
831
|
+
<div class='inline'><p>Whether the invocation was successful or not.</p>
|
832
|
+
</div>
|
833
|
+
|
834
|
+
</li>
|
835
|
+
|
836
|
+
</ul>
|
837
|
+
|
838
|
+
</div><table class="source_code">
|
839
|
+
<tr>
|
840
|
+
<td>
|
841
|
+
<pre class="lines">
|
842
|
+
|
843
|
+
|
844
|
+
20
|
845
|
+
21
|
846
|
+
22
|
847
|
+
23
|
848
|
+
24
|
849
|
+
25
|
850
|
+
26
|
851
|
+
27
|
852
|
+
28
|
853
|
+
29
|
854
|
+
30
|
855
|
+
31
|
856
|
+
32
|
857
|
+
33
|
858
|
+
34
|
859
|
+
35
|
860
|
+
36
|
861
|
+
37
|
862
|
+
38
|
863
|
+
39
|
864
|
+
40
|
865
|
+
41
|
866
|
+
42
|
867
|
+
43
|
868
|
+
44
|
869
|
+
45
|
870
|
+
46
|
871
|
+
47
|
872
|
+
48
|
873
|
+
49
|
874
|
+
50
|
875
|
+
51
|
876
|
+
52
|
877
|
+
53
|
878
|
+
54
|
879
|
+
55
|
880
|
+
56
|
881
|
+
57
|
882
|
+
58
|
883
|
+
59
|
884
|
+
60
|
885
|
+
61
|
886
|
+
62
|
887
|
+
63
|
888
|
+
64
|
889
|
+
65
|
890
|
+
66
|
891
|
+
67
|
892
|
+
68
|
893
|
+
69
|
894
|
+
70
|
895
|
+
71
|
896
|
+
72
|
897
|
+
73
|
898
|
+
74
|
899
|
+
75
|
900
|
+
76
|
901
|
+
77</pre>
|
902
|
+
</td>
|
903
|
+
<td>
|
904
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 20</span>
|
905
|
+
|
906
|
+
<span class='kw'>class</span> <span class='const'>Response</span>
|
907
|
+
<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>
|
908
|
+
|
909
|
+
<span class='comment'># Creates a new service response.
|
910
|
+
</span> <span class='comment'>#
|
911
|
+
</span> <span class='comment'># @param success [Boolean] Whether the invocation was successful or not.
|
912
|
+
</span> <span class='comment'># @param data [Object|NilClass] The data returned by the operation.
|
913
|
+
</span> <span class='comment'># @param errors [Array|NilClass] The errors returned by the operation.
|
914
|
+
</span> <span class='comment'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*
|
915
|
+
</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>
|
916
|
+
<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>
|
917
|
+
|
918
|
+
<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>
|
919
|
+
<span class='ivar'>@data</span> <span class='op'>=</span> <span class='id identifier rubyid_data'>data</span>
|
920
|
+
<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>
|
921
|
+
<span class='kw'>end</span>
|
922
|
+
|
923
|
+
<span class='comment'># Returns whether the invocation was successful or not.
|
924
|
+
</span> <span class='comment'>#
|
925
|
+
</span> <span class='comment'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.
|
926
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_success?'>success?</span>
|
927
|
+
<span class='comment'># TODO@PI: Ignore rubocop on this
|
928
|
+
</span> <span class='ivar'>@success</span>
|
929
|
+
<span class='kw'>end</span>
|
930
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:successful?</span><span class='comma'>,</span> <span class='symbol'>:success?</span>
|
931
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:succeeded?</span><span class='comma'>,</span> <span class='symbol'>:success?</span>
|
932
|
+
|
933
|
+
<span class='comment'># Returns whether the invocation failed or not.
|
934
|
+
</span> <span class='comment'>#
|
935
|
+
</span> <span class='comment'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.
|
936
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_fail?'>fail?</span>
|
937
|
+
<span class='op'>!</span><span class='ivar'>@success</span>
|
938
|
+
<span class='kw'>end</span>
|
939
|
+
<span class='id identifier rubyid_alias_method'>alias_method</span> <span class='symbol'>:failed?</span><span class='comma'>,</span> <span class='symbol'>:fail?</span>
|
940
|
+
|
941
|
+
<span class='comment'># Returns the first error returned by the operation.
|
942
|
+
</span> <span class='comment'>#
|
943
|
+
</span> <span class='comment'># @return [Object] The first error returned by the service.
|
944
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_error'>error</span>
|
945
|
+
<span class='ivar'>@errors</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
946
|
+
<span class='kw'>end</span>
|
947
|
+
|
948
|
+
<span class='comment'># Converts this response to a AJAX response.
|
949
|
+
</span> <span class='comment'>#
|
950
|
+
</span> <span class='comment'># @return [AjaxResponse] The AJAX response, which will include only the first error.
|
951
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_as_ajax_response'>as_ajax_response</span>
|
952
|
+
<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>
|
953
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_successful?'>successful?</span>
|
954
|
+
<span class='lbracket'>[</span><span class='symbol'>:ok</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rbracket'>]</span>
|
955
|
+
<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>
|
956
|
+
<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>
|
957
|
+
<span class='kw'>else</span>
|
958
|
+
<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>
|
959
|
+
<span class='kw'>end</span>
|
960
|
+
|
961
|
+
<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='rparen'>)</span>
|
962
|
+
<span class='kw'>end</span>
|
963
|
+
<span class='kw'>end</span></pre>
|
964
|
+
</td>
|
965
|
+
</tr>
|
966
|
+
</table>
|
967
|
+
</div>
|
968
|
+
|
969
|
+
</div>
|
970
|
+
|
971
|
+
|
972
|
+
<div id="instance_method_details" class="method_details_list">
|
973
|
+
<h2>Instance Method Details</h2>
|
974
|
+
|
975
|
+
|
976
|
+
<div class="method_details first">
|
977
|
+
<h3 class="signature first" id="as_ajax_response-instance_method">
|
978
|
+
|
979
|
+
- (<tt><span class='object_link'><a href="../AjaxResponse.html" title="Ballast::AjaxResponse (class)">AjaxResponse</a></span></tt>) <strong>as_ajax_response</strong>
|
980
|
+
|
981
|
+
|
982
|
+
|
983
|
+
|
984
|
+
|
985
|
+
</h3><div class="docstring">
|
986
|
+
<div class="discussion">
|
987
|
+
<p>Converts this response to a AJAX response.</p>
|
988
|
+
|
989
|
+
|
990
|
+
</div>
|
991
|
+
</div>
|
992
|
+
<div class="tags">
|
993
|
+
|
994
|
+
<p class="tag_title">Returns:</p>
|
995
|
+
<ul class="return">
|
996
|
+
|
997
|
+
<li>
|
998
|
+
|
999
|
+
|
1000
|
+
<span class='type'>(<tt><span class='object_link'><a href="../AjaxResponse.html" title="Ballast::AjaxResponse (class)">AjaxResponse</a></span></tt>)</span>
|
1001
|
+
|
1002
|
+
|
1003
|
+
|
1004
|
+
—
|
1005
|
+
<div class='inline'><p>The AJAX response, which will include only the first error.</p>
|
1006
|
+
</div>
|
1007
|
+
|
1008
|
+
</li>
|
1009
|
+
|
1010
|
+
</ul>
|
1011
|
+
|
1012
|
+
</div><table class="source_code">
|
1013
|
+
<tr>
|
1014
|
+
<td>
|
1015
|
+
<pre class="lines">
|
1016
|
+
|
1017
|
+
|
1018
|
+
65
|
1019
|
+
66
|
1020
|
+
67
|
1021
|
+
68
|
1022
|
+
69
|
1023
|
+
70
|
1024
|
+
71
|
1025
|
+
72
|
1026
|
+
73
|
1027
|
+
74
|
1028
|
+
75
|
1029
|
+
76</pre>
|
1030
|
+
</td>
|
1031
|
+
<td>
|
1032
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 65</span>
|
1033
|
+
|
1034
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_as_ajax_response'>as_ajax_response</span>
|
1035
|
+
<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>
|
1036
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_successful?'>successful?</span>
|
1037
|
+
<span class='lbracket'>[</span><span class='symbol'>:ok</span><span class='comma'>,</span> <span class='kw'>nil</span><span class='rbracket'>]</span>
|
1038
|
+
<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>
|
1039
|
+
<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>
|
1040
|
+
<span class='kw'>else</span>
|
1041
|
+
<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>
|
1042
|
+
<span class='kw'>end</span>
|
1043
|
+
|
1044
|
+
<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='rparen'>)</span>
|
1045
|
+
<span class='kw'>end</span></pre>
|
1046
|
+
</td>
|
1047
|
+
</tr>
|
1048
|
+
</table>
|
1049
|
+
</div>
|
1050
|
+
|
1051
|
+
<div class="method_details ">
|
1052
|
+
<h3 class="signature " id="error-instance_method">
|
1053
|
+
|
1054
|
+
- (<tt>Object</tt>) <strong>error</strong>
|
1055
|
+
|
1056
|
+
|
1057
|
+
|
1058
|
+
|
1059
|
+
|
1060
|
+
</h3><div class="docstring">
|
1061
|
+
<div class="discussion">
|
1062
|
+
<p>Returns the first error returned by the operation.</p>
|
1063
|
+
|
1064
|
+
|
1065
|
+
</div>
|
1066
|
+
</div>
|
1067
|
+
<div class="tags">
|
1068
|
+
|
1069
|
+
<p class="tag_title">Returns:</p>
|
1070
|
+
<ul class="return">
|
1071
|
+
|
1072
|
+
<li>
|
1073
|
+
|
1074
|
+
|
1075
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
1076
|
+
|
1077
|
+
|
1078
|
+
|
1079
|
+
—
|
1080
|
+
<div class='inline'><p>The first error returned by the service.</p>
|
1081
|
+
</div>
|
1082
|
+
|
1083
|
+
</li>
|
1084
|
+
|
1085
|
+
</ul>
|
1086
|
+
|
1087
|
+
</div><table class="source_code">
|
1088
|
+
<tr>
|
1089
|
+
<td>
|
1090
|
+
<pre class="lines">
|
1091
|
+
|
1092
|
+
|
1093
|
+
58
|
1094
|
+
59
|
1095
|
+
60</pre>
|
1096
|
+
</td>
|
1097
|
+
<td>
|
1098
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 58</span>
|
1099
|
+
|
1100
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_error'>error</span>
|
1101
|
+
<span class='ivar'>@errors</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span>
|
1102
|
+
<span class='kw'>end</span></pre>
|
1103
|
+
</td>
|
1104
|
+
</tr>
|
1105
|
+
</table>
|
1106
|
+
</div>
|
1107
|
+
|
1108
|
+
<div class="method_details ">
|
1109
|
+
<h3 class="signature " id="fail?-instance_method">
|
1110
|
+
|
1111
|
+
- (<tt>Boolean</tt>) <strong>fail?</strong>
|
1112
|
+
|
1113
|
+
|
1114
|
+
|
1115
|
+
<span class="aliases">Also known as:
|
1116
|
+
<span class="names"><span id='failed?-instance_method'>failed?</span></span>
|
1117
|
+
</span>
|
1118
|
+
|
1119
|
+
|
1120
|
+
|
1121
|
+
</h3><div class="docstring">
|
1122
|
+
<div class="discussion">
|
1123
|
+
<p>Returns whether the invocation failed or not.</p>
|
1124
|
+
|
1125
|
+
|
1126
|
+
</div>
|
1127
|
+
</div>
|
1128
|
+
<div class="tags">
|
1129
|
+
|
1130
|
+
<p class="tag_title">Returns:</p>
|
1131
|
+
<ul class="return">
|
1132
|
+
|
1133
|
+
<li>
|
1134
|
+
|
1135
|
+
|
1136
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1137
|
+
|
1138
|
+
|
1139
|
+
|
1140
|
+
—
|
1141
|
+
<div class='inline'><p><code>true</code> if the service invocation failed, <code>false</code> otherwise.</p>
|
1142
|
+
</div>
|
1143
|
+
|
1144
|
+
</li>
|
1145
|
+
|
1146
|
+
</ul>
|
1147
|
+
|
1148
|
+
</div><table class="source_code">
|
1149
|
+
<tr>
|
1150
|
+
<td>
|
1151
|
+
<pre class="lines">
|
1152
|
+
|
1153
|
+
|
1154
|
+
50
|
1155
|
+
51
|
1156
|
+
52</pre>
|
1157
|
+
</td>
|
1158
|
+
<td>
|
1159
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 50</span>
|
1160
|
+
|
1161
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_fail?'>fail?</span>
|
1162
|
+
<span class='op'>!</span><span class='ivar'>@success</span>
|
1163
|
+
<span class='kw'>end</span></pre>
|
1164
|
+
</td>
|
1165
|
+
</tr>
|
1166
|
+
</table>
|
1167
|
+
</div>
|
1168
|
+
|
1169
|
+
<div class="method_details ">
|
1170
|
+
<h3 class="signature " id="success?-instance_method">
|
1171
|
+
|
1172
|
+
- (<tt>Boolean</tt>) <strong>success?</strong>
|
1173
|
+
|
1174
|
+
|
1175
|
+
|
1176
|
+
<span class="aliases">Also known as:
|
1177
|
+
<span class="names"><span id='successful?-instance_method'>successful?</span>, <span id='succeeded?-instance_method'>succeeded?</span></span>
|
1178
|
+
</span>
|
1179
|
+
|
1180
|
+
|
1181
|
+
|
1182
|
+
</h3><div class="docstring">
|
1183
|
+
<div class="discussion">
|
1184
|
+
<p>Returns whether the invocation was successful or not.</p>
|
1185
|
+
|
1186
|
+
|
1187
|
+
</div>
|
1188
|
+
</div>
|
1189
|
+
<div class="tags">
|
1190
|
+
|
1191
|
+
<p class="tag_title">Returns:</p>
|
1192
|
+
<ul class="return">
|
1193
|
+
|
1194
|
+
<li>
|
1195
|
+
|
1196
|
+
|
1197
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
1198
|
+
|
1199
|
+
|
1200
|
+
|
1201
|
+
—
|
1202
|
+
<div class='inline'><p><code>true</code> if the service invocation was successful, <code>false</code> otherwise.</p>
|
1203
|
+
</div>
|
1204
|
+
|
1205
|
+
</li>
|
1206
|
+
|
1207
|
+
</ul>
|
1208
|
+
|
1209
|
+
</div><table class="source_code">
|
1210
|
+
<tr>
|
1211
|
+
<td>
|
1212
|
+
<pre class="lines">
|
1213
|
+
|
1214
|
+
|
1215
|
+
40
|
1216
|
+
41
|
1217
|
+
42
|
1218
|
+
43</pre>
|
1219
|
+
</td>
|
1220
|
+
<td>
|
1221
|
+
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 40</span>
|
1222
|
+
|
1223
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_success?'>success?</span>
|
1224
|
+
<span class='comment'># TODO@PI: Ignore rubocop on this
|
1225
|
+
</span> <span class='ivar'>@success</span>
|
1226
|
+
<span class='kw'>end</span></pre>
|
1227
|
+
</td>
|
1228
|
+
</tr>
|
1229
|
+
</table>
|
1230
|
+
</div>
|
1231
|
+
|
1232
|
+
</div>
|
1233
|
+
|
1234
|
+
</div>
|
1235
|
+
|
1236
|
+
<div id="footer">
|
1237
|
+
Generated on Sun Nov 2 09:40:01 2014 by
|
1238
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1239
|
+
0.8.7.6 (ruby-2.1.3).
|
1240
|
+
</div>
|
1241
|
+
|
1242
|
+
</body>
|
1243
|
+
</html>
|