ballast 2.2.4 → 2.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -1
- data/.travis-gemfile +2 -2
- data/.travis.yml +5 -3
- data/.yardopts +1 -1
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/LICENSE.md +21 -0
- data/README.md +22 -17
- data/Rakefile +1 -1
- data/ballast.gemspec +1 -1
- data/{doc → docs}/Ballast.html +19 -21
- data/docs/Ballast/AjaxResponse.html +1470 -0
- data/{doc → docs}/Ballast/Concerns.html +3 -3
- data/{doc → docs}/Ballast/Concerns/AjaxHandling.html +33 -38
- data/{doc → docs}/Ballast/Concerns/Common.html +45 -52
- data/{doc → docs}/Ballast/Concerns/ErrorsHandling.html +13 -14
- data/docs/Ballast/Concerns/JSONApi.html +127 -0
- data/docs/Ballast/Concerns/JSONApi/PaginationHandling.html +617 -0
- data/docs/Ballast/Concerns/JSONApi/RequestHandling.html +775 -0
- data/docs/Ballast/Concerns/JSONApi/ResponseHandling.html +917 -0
- data/{doc → docs}/Ballast/Concerns/View.html +35 -42
- data/{doc → docs}/Ballast/Configuration.html +19 -22
- data/{doc → docs}/Ballast/Emoji.html +1 -1
- data/{doc → docs}/Ballast/Emoji/Character.html +15 -18
- data/docs/Ballast/Emoji/Utils.html +794 -0
- data/{doc → docs}/Ballast/Errors.html +1 -1
- data/{doc → docs}/Ballast/Errors/Base.html +16 -18
- data/{doc → docs}/Ballast/Errors/Failure.html +1 -1
- data/{doc → docs}/Ballast/Errors/InvalidDomain.html +1 -1
- data/{doc → docs}/Ballast/Errors/ValidationFailure.html +1 -1
- data/{doc → docs}/Ballast/Middlewares.html +1 -1
- data/{doc → docs}/Ballast/Middlewares/DefaultHost.html +16 -18
- data/docs/Ballast/RequestDomainMatcher.html +917 -0
- data/docs/Ballast/Service.html +1513 -0
- data/docs/Ballast/Service/Response.html +1270 -0
- data/{doc → docs}/Ballast/Version.html +5 -9
- data/{doc → docs}/_index.html +45 -1
- data/docs/class_list.html +58 -0
- data/{doc → docs}/css/common.css +0 -0
- data/{doc → docs}/css/full_list.css +0 -0
- data/{doc → docs}/css/style.css +0 -0
- data/{doc → docs}/file.README.html +7 -5
- data/{doc → docs}/file_list.html +0 -0
- data/{doc → docs}/frames.html +0 -0
- data/{doc → docs}/index.html +7 -5
- data/{doc → docs}/js/app.js +0 -0
- data/{doc → docs}/js/full_list.js +0 -0
- data/{doc → docs}/js/jquery.js +0 -0
- data/{doc → docs}/method_list.html +150 -36
- data/docs/top-level-namespace.html +149 -0
- data/lib/ballast.rb +1 -1
- data/lib/ballast/ajax_response.rb +1 -1
- data/lib/ballast/concerns/ajax_handling.rb +1 -1
- data/lib/ballast/concerns/common.rb +1 -1
- data/lib/ballast/concerns/errors_handling.rb +1 -1
- data/lib/ballast/concerns/json_api/pagination_handling.rb +83 -0
- data/lib/ballast/concerns/json_api/request_handling.rb +235 -0
- data/lib/ballast/concerns/json_api/response_handling.rb +70 -0
- data/lib/ballast/concerns/view.rb +1 -1
- data/lib/ballast/configuration.rb +1 -1
- data/lib/ballast/emoji.rb +1 -1
- data/lib/ballast/errors.rb +1 -1
- data/lib/ballast/middlewares/default_host.rb +1 -1
- data/lib/ballast/request_domain_matcher.rb +1 -1
- data/lib/ballast/service.rb +1 -1
- data/lib/ballast/version.rb +2 -2
- data/spec/ballast/ajax_response_spec.rb +1 -1
- data/spec/ballast/concerns/ajax_handling_spec.rb +1 -1
- data/spec/ballast/concerns/common_spec.rb +1 -1
- data/spec/ballast/concerns/errors_handling_spec.rb +1 -1
- data/spec/ballast/concerns/view_spec.rb +1 -1
- data/spec/ballast/configuration_spec.rb +1 -1
- data/spec/ballast/errors_spec.rb +1 -1
- data/spec/ballast/middlewares/default_host_spec.rb +1 -1
- data/spec/ballast/request_domain_matcher_spec.rb +1 -1
- data/spec/ballast_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- metadata +47 -39
- data/doc/Ballast/AjaxResponse.html +0 -1478
- data/doc/Ballast/Emoji/Utils.html +0 -799
- data/doc/Ballast/RequestDomainMatcher.html +0 -923
- data/doc/Ballast/Service.html +0 -1522
- data/doc/Ballast/Service/Response.html +0 -1278
- data/doc/class_list.html +0 -58
- data/doc/top-level-namespace.html +0 -112
@@ -1,1278 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
-
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
-
<title>
|
7
|
-
Class: Ballast::Service::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>(transport = nil) </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='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_success identifier id'>success</span> <span class='assign token'>=</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>errors:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
446
|
-
<span class='rubyid_errors identifier id'>errors</span> <span class='opasgn op'>||=</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span>
|
447
|
-
|
448
|
-
<span class='rubyid_@success ivar id'>@success</span> <span class='assign token'>=</span> <span class='rubyid_success identifier id'>success</span><span class='dot token'>.</span><span class='rubyid_to_boolean identifier id'>to_boolean</span>
|
449
|
-
<span class='rubyid_@data ivar id'>@data</span> <span class='assign token'>=</span> <span class='rubyid_data identifier id'>data</span>
|
450
|
-
<span class='rubyid_@errors ivar id'>@errors</span> <span class='assign token'>=</span> <span class='rubyid_errors identifier id'>errors</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span><span class='lparen token'>(</span><span class='label val'>no_duplicates:</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>compact:</span> <span class='rubyid_true true kw'>true</span><span class='rparen token'>)</span>
|
451
|
-
<span class='rubyid_end end kw'>end</span>
|
452
|
-
</pre>
|
453
|
-
</td>
|
454
|
-
</tr>
|
455
|
-
</table>
|
456
|
-
</div>
|
457
|
-
|
458
|
-
</div>
|
459
|
-
|
460
|
-
<div id="instance_attr_details" class="attr_details">
|
461
|
-
<h2>Instance Attribute Details</h2>
|
462
|
-
|
463
|
-
|
464
|
-
<span id=""></span>
|
465
|
-
<div class="method_details first">
|
466
|
-
<h3 class="signature first" id="data-instance_method">
|
467
|
-
|
468
|
-
- (<tt>Object</tt>) <strong>data</strong> <span class="extras">(readonly)</span>
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
</h3><div class="docstring">
|
475
|
-
<div class="discussion">
|
476
|
-
<p>Returns The data returned by the operation.</p>
|
477
|
-
|
478
|
-
|
479
|
-
</div>
|
480
|
-
</div>
|
481
|
-
<div class="tags">
|
482
|
-
|
483
|
-
<p class="tag_title">Returns:</p>
|
484
|
-
<ul class="return">
|
485
|
-
|
486
|
-
<li>
|
487
|
-
|
488
|
-
|
489
|
-
<span class='type'>(<tt>Object</tt>)</span>
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
—
|
494
|
-
<div class='inline'><p>The data returned by the operation.</p>
|
495
|
-
</div>
|
496
|
-
|
497
|
-
</li>
|
498
|
-
|
499
|
-
</ul>
|
500
|
-
|
501
|
-
</div><table class="source_code">
|
502
|
-
<tr>
|
503
|
-
<td>
|
504
|
-
<pre class="lines">
|
505
|
-
|
506
|
-
|
507
|
-
20
|
508
|
-
21
|
509
|
-
22
|
510
|
-
23
|
511
|
-
24
|
512
|
-
25
|
513
|
-
26
|
514
|
-
27
|
515
|
-
28
|
516
|
-
29
|
517
|
-
30
|
518
|
-
31
|
519
|
-
32
|
520
|
-
33
|
521
|
-
34
|
522
|
-
35
|
523
|
-
36
|
524
|
-
37
|
525
|
-
38
|
526
|
-
39
|
527
|
-
40
|
528
|
-
41
|
529
|
-
42
|
530
|
-
43
|
531
|
-
44
|
532
|
-
45
|
533
|
-
46
|
534
|
-
47
|
535
|
-
48
|
536
|
-
49
|
537
|
-
50
|
538
|
-
51
|
539
|
-
52
|
540
|
-
53
|
541
|
-
54
|
542
|
-
55
|
543
|
-
56
|
544
|
-
57
|
545
|
-
58
|
546
|
-
59
|
547
|
-
60
|
548
|
-
61
|
549
|
-
62
|
550
|
-
63
|
551
|
-
64
|
552
|
-
65
|
553
|
-
66
|
554
|
-
67
|
555
|
-
68
|
556
|
-
69
|
557
|
-
70
|
558
|
-
71
|
559
|
-
72
|
560
|
-
73
|
561
|
-
74
|
562
|
-
75
|
563
|
-
76
|
564
|
-
77
|
565
|
-
78</pre>
|
566
|
-
</td>
|
567
|
-
<td>
|
568
|
-
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 20</span>
|
569
|
-
|
570
|
-
<span class='rubyid_class class kw'>class</span> <span class='rubyid_Response constant id'>Response</span>
|
571
|
-
<span class='rubyid_attr_reader identifier id'>attr_reader</span> <span class='symbol val'>:success</span><span class='comma token'>,</span> <span class='symbol val'>:data</span><span class='comma token'>,</span> <span class='symbol val'>:errors</span>
|
572
|
-
|
573
|
-
<span class='comment val'># Creates a new service response.</span>
|
574
|
-
<span class='comment val'>#</span>
|
575
|
-
<span class='comment val'># @param success [Boolean] Whether the invocation was successful or not.</span>
|
576
|
-
<span class='comment val'># @param data [Object|NilClass] The data returned by the operation.</span>
|
577
|
-
<span class='comment val'># @param errors [Array|NilClass] The errors returned by the operation.</span>
|
578
|
-
<span class='comment val'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*</span>
|
579
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_success identifier id'>success</span> <span class='assign token'>=</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>errors:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
580
|
-
<span class='rubyid_errors identifier id'>errors</span> <span class='opasgn op'>||=</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span>
|
581
|
-
|
582
|
-
<span class='rubyid_@success ivar id'>@success</span> <span class='assign token'>=</span> <span class='rubyid_success identifier id'>success</span><span class='dot token'>.</span><span class='rubyid_to_boolean identifier id'>to_boolean</span>
|
583
|
-
<span class='rubyid_@data ivar id'>@data</span> <span class='assign token'>=</span> <span class='rubyid_data identifier id'>data</span>
|
584
|
-
<span class='rubyid_@errors ivar id'>@errors</span> <span class='assign token'>=</span> <span class='rubyid_errors identifier id'>errors</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span><span class='lparen token'>(</span><span class='label val'>no_duplicates:</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>compact:</span> <span class='rubyid_true true kw'>true</span><span class='rparen token'>)</span>
|
585
|
-
<span class='rubyid_end end kw'>end</span>
|
586
|
-
|
587
|
-
<span class='comment val'># Returns whether the invocation was successful or not.</span>
|
588
|
-
<span class='comment val'>#</span>
|
589
|
-
<span class='comment val'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.</span>
|
590
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_success? fid id'>success?</span>
|
591
|
-
<span class='comment val'># TODO@PI: Ignore rubocop on this</span>
|
592
|
-
<span class='rubyid_@success ivar id'>@success</span>
|
593
|
-
<span class='rubyid_end end kw'>end</span>
|
594
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:successful?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
|
595
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:succeeded?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
|
596
|
-
|
597
|
-
<span class='comment val'># Returns whether the invocation failed or not.</span>
|
598
|
-
<span class='comment val'>#</span>
|
599
|
-
<span class='comment val'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.</span>
|
600
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_fail? fid id'>fail?</span>
|
601
|
-
<span class='notop op'>!</span><span class='rubyid_@success ivar id'>@success</span>
|
602
|
-
<span class='rubyid_end end kw'>end</span>
|
603
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:failed?</span><span class='comma token'>,</span> <span class='symbol val'>:fail?</span>
|
604
|
-
|
605
|
-
<span class='comment val'># Returns the first error returned by the operation.</span>
|
606
|
-
<span class='comment val'>#</span>
|
607
|
-
<span class='comment val'># @return [Object] The first error returned by the service.</span>
|
608
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_error identifier id'>error</span>
|
609
|
-
<span class='rubyid_@errors ivar id'>@errors</span><span class='dot token'>.</span><span class='rubyid_first identifier id'>first</span>
|
610
|
-
<span class='rubyid_end end kw'>end</span>
|
611
|
-
|
612
|
-
<span class='comment val'># Converts this response to a AJAX response.</span>
|
613
|
-
<span class='comment val'>#</span>
|
614
|
-
<span class='comment val'># @param transport [Object|NilClass] The transport to use for sending. Must respond to `render`, `params`, `request.format` and `performed?`.</span>
|
615
|
-
<span class='comment val'># @return [AjaxResponse] The AJAX response, which will include only the first error.</span>
|
616
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_as_ajax_response identifier id'>as_ajax_response</span><span class='lparen token'>(</span><span class='rubyid_transport identifier id'>transport</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
617
|
-
<span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='rubyid_error_message identifier id'>error_message</span> <span class='assign token'>=</span>
|
618
|
-
<span class='rubyid_if if kw'>if</span> <span class='rubyid_successful? fid id'>successful?</span>
|
619
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:ok</span><span class='comma token'>,</span> <span class='rubyid_nil nil kw'>nil</span><span class='rbrack token'>]</span>
|
620
|
-
<span class='rubyid_elsif elsif kw'>elsif</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
621
|
-
<span class='lbrack token'>[</span><span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:status</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
|
622
|
-
<span class='rubyid_else else kw'>else</span>
|
623
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:unknown</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='rbrack token'>]</span>
|
624
|
-
<span class='rubyid_end end kw'>end</span>
|
625
|
-
|
626
|
-
<span class='rubyid_AjaxResponse constant id'>AjaxResponse</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_data identifier id'>data</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_error_message identifier id'>error_message</span><span class='comma token'>,</span> <span class='label val'>transport:</span> <span class='rubyid_transport identifier id'>transport</span><span class='rparen token'>)</span>
|
627
|
-
<span class='rubyid_end end kw'>end</span>
|
628
|
-
<span class='rubyid_end end kw'>end</span>
|
629
|
-
</pre>
|
630
|
-
</td>
|
631
|
-
</tr>
|
632
|
-
</table>
|
633
|
-
</div>
|
634
|
-
|
635
|
-
|
636
|
-
<span id=""></span>
|
637
|
-
<div class="method_details ">
|
638
|
-
<h3 class="signature " id="errors-instance_method">
|
639
|
-
|
640
|
-
- (<tt>Array</tt>) <strong>errors</strong> <span class="extras">(readonly)</span>
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
</h3><div class="docstring">
|
647
|
-
<div class="discussion">
|
648
|
-
<p>Returns The errors returned by the operation.</p>
|
649
|
-
|
650
|
-
|
651
|
-
</div>
|
652
|
-
</div>
|
653
|
-
<div class="tags">
|
654
|
-
|
655
|
-
<p class="tag_title">Returns:</p>
|
656
|
-
<ul class="return">
|
657
|
-
|
658
|
-
<li>
|
659
|
-
|
660
|
-
|
661
|
-
<span class='type'>(<tt>Array</tt>)</span>
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
—
|
666
|
-
<div class='inline'><p>The errors returned by the operation.</p>
|
667
|
-
</div>
|
668
|
-
|
669
|
-
</li>
|
670
|
-
|
671
|
-
</ul>
|
672
|
-
|
673
|
-
</div><table class="source_code">
|
674
|
-
<tr>
|
675
|
-
<td>
|
676
|
-
<pre class="lines">
|
677
|
-
|
678
|
-
|
679
|
-
20
|
680
|
-
21
|
681
|
-
22
|
682
|
-
23
|
683
|
-
24
|
684
|
-
25
|
685
|
-
26
|
686
|
-
27
|
687
|
-
28
|
688
|
-
29
|
689
|
-
30
|
690
|
-
31
|
691
|
-
32
|
692
|
-
33
|
693
|
-
34
|
694
|
-
35
|
695
|
-
36
|
696
|
-
37
|
697
|
-
38
|
698
|
-
39
|
699
|
-
40
|
700
|
-
41
|
701
|
-
42
|
702
|
-
43
|
703
|
-
44
|
704
|
-
45
|
705
|
-
46
|
706
|
-
47
|
707
|
-
48
|
708
|
-
49
|
709
|
-
50
|
710
|
-
51
|
711
|
-
52
|
712
|
-
53
|
713
|
-
54
|
714
|
-
55
|
715
|
-
56
|
716
|
-
57
|
717
|
-
58
|
718
|
-
59
|
719
|
-
60
|
720
|
-
61
|
721
|
-
62
|
722
|
-
63
|
723
|
-
64
|
724
|
-
65
|
725
|
-
66
|
726
|
-
67
|
727
|
-
68
|
728
|
-
69
|
729
|
-
70
|
730
|
-
71
|
731
|
-
72
|
732
|
-
73
|
733
|
-
74
|
734
|
-
75
|
735
|
-
76
|
736
|
-
77
|
737
|
-
78</pre>
|
738
|
-
</td>
|
739
|
-
<td>
|
740
|
-
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 20</span>
|
741
|
-
|
742
|
-
<span class='rubyid_class class kw'>class</span> <span class='rubyid_Response constant id'>Response</span>
|
743
|
-
<span class='rubyid_attr_reader identifier id'>attr_reader</span> <span class='symbol val'>:success</span><span class='comma token'>,</span> <span class='symbol val'>:data</span><span class='comma token'>,</span> <span class='symbol val'>:errors</span>
|
744
|
-
|
745
|
-
<span class='comment val'># Creates a new service response.</span>
|
746
|
-
<span class='comment val'>#</span>
|
747
|
-
<span class='comment val'># @param success [Boolean] Whether the invocation was successful or not.</span>
|
748
|
-
<span class='comment val'># @param data [Object|NilClass] The data returned by the operation.</span>
|
749
|
-
<span class='comment val'># @param errors [Array|NilClass] The errors returned by the operation.</span>
|
750
|
-
<span class='comment val'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*</span>
|
751
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_success identifier id'>success</span> <span class='assign token'>=</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>errors:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
752
|
-
<span class='rubyid_errors identifier id'>errors</span> <span class='opasgn op'>||=</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span>
|
753
|
-
|
754
|
-
<span class='rubyid_@success ivar id'>@success</span> <span class='assign token'>=</span> <span class='rubyid_success identifier id'>success</span><span class='dot token'>.</span><span class='rubyid_to_boolean identifier id'>to_boolean</span>
|
755
|
-
<span class='rubyid_@data ivar id'>@data</span> <span class='assign token'>=</span> <span class='rubyid_data identifier id'>data</span>
|
756
|
-
<span class='rubyid_@errors ivar id'>@errors</span> <span class='assign token'>=</span> <span class='rubyid_errors identifier id'>errors</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span><span class='lparen token'>(</span><span class='label val'>no_duplicates:</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>compact:</span> <span class='rubyid_true true kw'>true</span><span class='rparen token'>)</span>
|
757
|
-
<span class='rubyid_end end kw'>end</span>
|
758
|
-
|
759
|
-
<span class='comment val'># Returns whether the invocation was successful or not.</span>
|
760
|
-
<span class='comment val'>#</span>
|
761
|
-
<span class='comment val'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.</span>
|
762
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_success? fid id'>success?</span>
|
763
|
-
<span class='comment val'># TODO@PI: Ignore rubocop on this</span>
|
764
|
-
<span class='rubyid_@success ivar id'>@success</span>
|
765
|
-
<span class='rubyid_end end kw'>end</span>
|
766
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:successful?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
|
767
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:succeeded?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
|
768
|
-
|
769
|
-
<span class='comment val'># Returns whether the invocation failed or not.</span>
|
770
|
-
<span class='comment val'>#</span>
|
771
|
-
<span class='comment val'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.</span>
|
772
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_fail? fid id'>fail?</span>
|
773
|
-
<span class='notop op'>!</span><span class='rubyid_@success ivar id'>@success</span>
|
774
|
-
<span class='rubyid_end end kw'>end</span>
|
775
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:failed?</span><span class='comma token'>,</span> <span class='symbol val'>:fail?</span>
|
776
|
-
|
777
|
-
<span class='comment val'># Returns the first error returned by the operation.</span>
|
778
|
-
<span class='comment val'>#</span>
|
779
|
-
<span class='comment val'># @return [Object] The first error returned by the service.</span>
|
780
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_error identifier id'>error</span>
|
781
|
-
<span class='rubyid_@errors ivar id'>@errors</span><span class='dot token'>.</span><span class='rubyid_first identifier id'>first</span>
|
782
|
-
<span class='rubyid_end end kw'>end</span>
|
783
|
-
|
784
|
-
<span class='comment val'># Converts this response to a AJAX response.</span>
|
785
|
-
<span class='comment val'>#</span>
|
786
|
-
<span class='comment val'># @param transport [Object|NilClass] The transport to use for sending. Must respond to `render`, `params`, `request.format` and `performed?`.</span>
|
787
|
-
<span class='comment val'># @return [AjaxResponse] The AJAX response, which will include only the first error.</span>
|
788
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_as_ajax_response identifier id'>as_ajax_response</span><span class='lparen token'>(</span><span class='rubyid_transport identifier id'>transport</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
789
|
-
<span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='rubyid_error_message identifier id'>error_message</span> <span class='assign token'>=</span>
|
790
|
-
<span class='rubyid_if if kw'>if</span> <span class='rubyid_successful? fid id'>successful?</span>
|
791
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:ok</span><span class='comma token'>,</span> <span class='rubyid_nil nil kw'>nil</span><span class='rbrack token'>]</span>
|
792
|
-
<span class='rubyid_elsif elsif kw'>elsif</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
793
|
-
<span class='lbrack token'>[</span><span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:status</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
|
794
|
-
<span class='rubyid_else else kw'>else</span>
|
795
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:unknown</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='rbrack token'>]</span>
|
796
|
-
<span class='rubyid_end end kw'>end</span>
|
797
|
-
|
798
|
-
<span class='rubyid_AjaxResponse constant id'>AjaxResponse</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_data identifier id'>data</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_error_message identifier id'>error_message</span><span class='comma token'>,</span> <span class='label val'>transport:</span> <span class='rubyid_transport identifier id'>transport</span><span class='rparen token'>)</span>
|
799
|
-
<span class='rubyid_end end kw'>end</span>
|
800
|
-
<span class='rubyid_end end kw'>end</span>
|
801
|
-
</pre>
|
802
|
-
</td>
|
803
|
-
</tr>
|
804
|
-
</table>
|
805
|
-
</div>
|
806
|
-
|
807
|
-
|
808
|
-
<span id=""></span>
|
809
|
-
<div class="method_details ">
|
810
|
-
<h3 class="signature " id="success-instance_method">
|
811
|
-
|
812
|
-
- (<tt>Boolean</tt>) <strong>success</strong> <span class="extras">(readonly)</span>
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
</h3><div class="docstring">
|
819
|
-
<div class="discussion">
|
820
|
-
<p>Returns Whether the invocation was successful or not.</p>
|
821
|
-
|
822
|
-
|
823
|
-
</div>
|
824
|
-
</div>
|
825
|
-
<div class="tags">
|
826
|
-
|
827
|
-
<p class="tag_title">Returns:</p>
|
828
|
-
<ul class="return">
|
829
|
-
|
830
|
-
<li>
|
831
|
-
|
832
|
-
|
833
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
—
|
838
|
-
<div class='inline'><p>Whether the invocation was successful or not.</p>
|
839
|
-
</div>
|
840
|
-
|
841
|
-
</li>
|
842
|
-
|
843
|
-
</ul>
|
844
|
-
|
845
|
-
</div><table class="source_code">
|
846
|
-
<tr>
|
847
|
-
<td>
|
848
|
-
<pre class="lines">
|
849
|
-
|
850
|
-
|
851
|
-
20
|
852
|
-
21
|
853
|
-
22
|
854
|
-
23
|
855
|
-
24
|
856
|
-
25
|
857
|
-
26
|
858
|
-
27
|
859
|
-
28
|
860
|
-
29
|
861
|
-
30
|
862
|
-
31
|
863
|
-
32
|
864
|
-
33
|
865
|
-
34
|
866
|
-
35
|
867
|
-
36
|
868
|
-
37
|
869
|
-
38
|
870
|
-
39
|
871
|
-
40
|
872
|
-
41
|
873
|
-
42
|
874
|
-
43
|
875
|
-
44
|
876
|
-
45
|
877
|
-
46
|
878
|
-
47
|
879
|
-
48
|
880
|
-
49
|
881
|
-
50
|
882
|
-
51
|
883
|
-
52
|
884
|
-
53
|
885
|
-
54
|
886
|
-
55
|
887
|
-
56
|
888
|
-
57
|
889
|
-
58
|
890
|
-
59
|
891
|
-
60
|
892
|
-
61
|
893
|
-
62
|
894
|
-
63
|
895
|
-
64
|
896
|
-
65
|
897
|
-
66
|
898
|
-
67
|
899
|
-
68
|
900
|
-
69
|
901
|
-
70
|
902
|
-
71
|
903
|
-
72
|
904
|
-
73
|
905
|
-
74
|
906
|
-
75
|
907
|
-
76
|
908
|
-
77
|
909
|
-
78</pre>
|
910
|
-
</td>
|
911
|
-
<td>
|
912
|
-
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 20</span>
|
913
|
-
|
914
|
-
<span class='rubyid_class class kw'>class</span> <span class='rubyid_Response constant id'>Response</span>
|
915
|
-
<span class='rubyid_attr_reader identifier id'>attr_reader</span> <span class='symbol val'>:success</span><span class='comma token'>,</span> <span class='symbol val'>:data</span><span class='comma token'>,</span> <span class='symbol val'>:errors</span>
|
916
|
-
|
917
|
-
<span class='comment val'># Creates a new service response.</span>
|
918
|
-
<span class='comment val'>#</span>
|
919
|
-
<span class='comment val'># @param success [Boolean] Whether the invocation was successful or not.</span>
|
920
|
-
<span class='comment val'># @param data [Object|NilClass] The data returned by the operation.</span>
|
921
|
-
<span class='comment val'># @param errors [Array|NilClass] The errors returned by the operation.</span>
|
922
|
-
<span class='comment val'># @param error [Object|NilClass] Alias for errors. *Ignored if `errors` is present.*</span>
|
923
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_initialize identifier id'>initialize</span><span class='lparen token'>(</span><span class='rubyid_success identifier id'>success</span> <span class='assign token'>=</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>errors:</span> <span class='rubyid_nil nil kw'>nil</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
924
|
-
<span class='rubyid_errors identifier id'>errors</span> <span class='opasgn op'>||=</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span>
|
925
|
-
|
926
|
-
<span class='rubyid_@success ivar id'>@success</span> <span class='assign token'>=</span> <span class='rubyid_success identifier id'>success</span><span class='dot token'>.</span><span class='rubyid_to_boolean identifier id'>to_boolean</span>
|
927
|
-
<span class='rubyid_@data ivar id'>@data</span> <span class='assign token'>=</span> <span class='rubyid_data identifier id'>data</span>
|
928
|
-
<span class='rubyid_@errors ivar id'>@errors</span> <span class='assign token'>=</span> <span class='rubyid_errors identifier id'>errors</span><span class='dot token'>.</span><span class='rubyid_ensure_array identifier id'>ensure_array</span><span class='lparen token'>(</span><span class='label val'>no_duplicates:</span> <span class='rubyid_true true kw'>true</span><span class='comma token'>,</span> <span class='label val'>compact:</span> <span class='rubyid_true true kw'>true</span><span class='rparen token'>)</span>
|
929
|
-
<span class='rubyid_end end kw'>end</span>
|
930
|
-
|
931
|
-
<span class='comment val'># Returns whether the invocation was successful or not.</span>
|
932
|
-
<span class='comment val'>#</span>
|
933
|
-
<span class='comment val'># @return [Boolean] `true` if the service invocation was successful, `false` otherwise.</span>
|
934
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_success? fid id'>success?</span>
|
935
|
-
<span class='comment val'># TODO@PI: Ignore rubocop on this</span>
|
936
|
-
<span class='rubyid_@success ivar id'>@success</span>
|
937
|
-
<span class='rubyid_end end kw'>end</span>
|
938
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:successful?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
|
939
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:succeeded?</span><span class='comma token'>,</span> <span class='symbol val'>:success?</span>
|
940
|
-
|
941
|
-
<span class='comment val'># Returns whether the invocation failed or not.</span>
|
942
|
-
<span class='comment val'>#</span>
|
943
|
-
<span class='comment val'># @return [Boolean] `true` if the service invocation failed, `false` otherwise.</span>
|
944
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_fail? fid id'>fail?</span>
|
945
|
-
<span class='notop op'>!</span><span class='rubyid_@success ivar id'>@success</span>
|
946
|
-
<span class='rubyid_end end kw'>end</span>
|
947
|
-
<span class='rubyid_alias_method identifier id'>alias_method</span> <span class='symbol val'>:failed?</span><span class='comma token'>,</span> <span class='symbol val'>:fail?</span>
|
948
|
-
|
949
|
-
<span class='comment val'># Returns the first error returned by the operation.</span>
|
950
|
-
<span class='comment val'>#</span>
|
951
|
-
<span class='comment val'># @return [Object] The first error returned by the service.</span>
|
952
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_error identifier id'>error</span>
|
953
|
-
<span class='rubyid_@errors ivar id'>@errors</span><span class='dot token'>.</span><span class='rubyid_first identifier id'>first</span>
|
954
|
-
<span class='rubyid_end end kw'>end</span>
|
955
|
-
|
956
|
-
<span class='comment val'># Converts this response to a AJAX response.</span>
|
957
|
-
<span class='comment val'>#</span>
|
958
|
-
<span class='comment val'># @param transport [Object|NilClass] The transport to use for sending. Must respond to `render`, `params`, `request.format` and `performed?`.</span>
|
959
|
-
<span class='comment val'># @return [AjaxResponse] The AJAX response, which will include only the first error.</span>
|
960
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_as_ajax_response identifier id'>as_ajax_response</span><span class='lparen token'>(</span><span class='rubyid_transport identifier id'>transport</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
961
|
-
<span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='rubyid_error_message identifier id'>error_message</span> <span class='assign token'>=</span>
|
962
|
-
<span class='rubyid_if if kw'>if</span> <span class='rubyid_successful? fid id'>successful?</span>
|
963
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:ok</span><span class='comma token'>,</span> <span class='rubyid_nil nil kw'>nil</span><span class='rbrack token'>]</span>
|
964
|
-
<span class='rubyid_elsif elsif kw'>elsif</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
965
|
-
<span class='lbrack token'>[</span><span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:status</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
|
966
|
-
<span class='rubyid_else else kw'>else</span>
|
967
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:unknown</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='rbrack token'>]</span>
|
968
|
-
<span class='rubyid_end end kw'>end</span>
|
969
|
-
|
970
|
-
<span class='rubyid_AjaxResponse constant id'>AjaxResponse</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_data identifier id'>data</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_error_message identifier id'>error_message</span><span class='comma token'>,</span> <span class='label val'>transport:</span> <span class='rubyid_transport identifier id'>transport</span><span class='rparen token'>)</span>
|
971
|
-
<span class='rubyid_end end kw'>end</span>
|
972
|
-
<span class='rubyid_end end kw'>end</span>
|
973
|
-
</pre>
|
974
|
-
</td>
|
975
|
-
</tr>
|
976
|
-
</table>
|
977
|
-
</div>
|
978
|
-
|
979
|
-
</div>
|
980
|
-
|
981
|
-
|
982
|
-
<div id="instance_method_details" class="method_details_list">
|
983
|
-
<h2>Instance Method Details</h2>
|
984
|
-
|
985
|
-
|
986
|
-
<div class="method_details first">
|
987
|
-
<h3 class="signature first" id="as_ajax_response-instance_method">
|
988
|
-
|
989
|
-
- (<tt><span class='object_link'><a href="../AjaxResponse.html" title="Ballast::AjaxResponse (class)">AjaxResponse</a></span></tt>) <strong>as_ajax_response</strong>(transport = nil)
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
</h3><div class="docstring">
|
996
|
-
<div class="discussion">
|
997
|
-
<p>Converts this response to a AJAX response.</p>
|
998
|
-
|
999
|
-
|
1000
|
-
</div>
|
1001
|
-
</div>
|
1002
|
-
<div class="tags">
|
1003
|
-
<p class="tag_title">Parameters:</p>
|
1004
|
-
<ul class="param">
|
1005
|
-
|
1006
|
-
<li>
|
1007
|
-
|
1008
|
-
<span class='name'>transport</span>
|
1009
|
-
|
1010
|
-
|
1011
|
-
<span class='type'>(<tt>Object|NilClass</tt>)</span>
|
1012
|
-
|
1013
|
-
|
1014
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
1015
|
-
|
1016
|
-
|
1017
|
-
—
|
1018
|
-
<div class='inline'><p>The transport to use for sending. Must respond to <code>render</code>, <code>params</code>, <code>request.format</code> and <code>performed?</code>.</p>
|
1019
|
-
</div>
|
1020
|
-
|
1021
|
-
</li>
|
1022
|
-
|
1023
|
-
</ul>
|
1024
|
-
|
1025
|
-
<p class="tag_title">Returns:</p>
|
1026
|
-
<ul class="return">
|
1027
|
-
|
1028
|
-
<li>
|
1029
|
-
|
1030
|
-
|
1031
|
-
<span class='type'>(<tt><span class='object_link'><a href="../AjaxResponse.html" title="Ballast::AjaxResponse (class)">AjaxResponse</a></span></tt>)</span>
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
—
|
1036
|
-
<div class='inline'><p>The AJAX response, which will include only the first error.</p>
|
1037
|
-
</div>
|
1038
|
-
|
1039
|
-
</li>
|
1040
|
-
|
1041
|
-
</ul>
|
1042
|
-
|
1043
|
-
</div><table class="source_code">
|
1044
|
-
<tr>
|
1045
|
-
<td>
|
1046
|
-
<pre class="lines">
|
1047
|
-
|
1048
|
-
|
1049
|
-
66
|
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/service.rb', line 66</span>
|
1064
|
-
|
1065
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_as_ajax_response identifier id'>as_ajax_response</span><span class='lparen token'>(</span><span class='rubyid_transport identifier id'>transport</span> <span class='assign token'>=</span> <span class='rubyid_nil nil kw'>nil</span><span class='rparen token'>)</span>
|
1066
|
-
<span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='rubyid_error_message identifier id'>error_message</span> <span class='assign token'>=</span>
|
1067
|
-
<span class='rubyid_if if kw'>if</span> <span class='rubyid_successful? fid id'>successful?</span>
|
1068
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:ok</span><span class='comma token'>,</span> <span class='rubyid_nil nil kw'>nil</span><span class='rbrack token'>]</span>
|
1069
|
-
<span class='rubyid_elsif elsif kw'>elsif</span> <span class='rubyid_error identifier id'>error</span><span class='dot token'>.</span><span class='rubyid_is_a? fid id'>is_a?</span><span class='lparen token'>(</span><span class='rubyid_Hash constant id'>Hash</span><span class='rparen token'>)</span>
|
1070
|
-
<span class='lbrack token'>[</span><span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:status</span><span class='rbrack token'>]</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='lbrack token'>[</span><span class='symbol val'>:error</span><span class='rbrack token'>]</span><span class='rbrack token'>]</span>
|
1071
|
-
<span class='rubyid_else else kw'>else</span>
|
1072
|
-
<span class='lbrack token'>[</span><span class='symbol val'>:unknown</span><span class='comma token'>,</span> <span class='rubyid_error identifier id'>error</span><span class='rbrack token'>]</span>
|
1073
|
-
<span class='rubyid_end end kw'>end</span>
|
1074
|
-
|
1075
|
-
<span class='rubyid_AjaxResponse constant id'>AjaxResponse</span><span class='dot token'>.</span><span class='rubyid_new identifier id'>new</span><span class='lparen token'>(</span><span class='label val'>status:</span> <span class='rubyid_status identifier id'>status</span><span class='comma token'>,</span> <span class='label val'>data:</span> <span class='rubyid_data identifier id'>data</span><span class='comma token'>,</span> <span class='label val'>error:</span> <span class='rubyid_error_message identifier id'>error_message</span><span class='comma token'>,</span> <span class='label val'>transport:</span> <span class='rubyid_transport identifier id'>transport</span><span class='rparen token'>)</span>
|
1076
|
-
<span class='rubyid_end end kw'>end</span>
|
1077
|
-
</pre>
|
1078
|
-
</td>
|
1079
|
-
</tr>
|
1080
|
-
</table>
|
1081
|
-
</div>
|
1082
|
-
|
1083
|
-
<div class="method_details ">
|
1084
|
-
<h3 class="signature " id="error-instance_method">
|
1085
|
-
|
1086
|
-
- (<tt>Object</tt>) <strong>error</strong>
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1092
|
-
</h3><div class="docstring">
|
1093
|
-
<div class="discussion">
|
1094
|
-
<p>Returns the first error returned by the operation.</p>
|
1095
|
-
|
1096
|
-
|
1097
|
-
</div>
|
1098
|
-
</div>
|
1099
|
-
<div class="tags">
|
1100
|
-
|
1101
|
-
<p class="tag_title">Returns:</p>
|
1102
|
-
<ul class="return">
|
1103
|
-
|
1104
|
-
<li>
|
1105
|
-
|
1106
|
-
|
1107
|
-
<span class='type'>(<tt>Object</tt>)</span>
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
—
|
1112
|
-
<div class='inline'><p>The first error returned by the service.</p>
|
1113
|
-
</div>
|
1114
|
-
|
1115
|
-
</li>
|
1116
|
-
|
1117
|
-
</ul>
|
1118
|
-
|
1119
|
-
</div><table class="source_code">
|
1120
|
-
<tr>
|
1121
|
-
<td>
|
1122
|
-
<pre class="lines">
|
1123
|
-
|
1124
|
-
|
1125
|
-
58
|
1126
|
-
59
|
1127
|
-
60</pre>
|
1128
|
-
</td>
|
1129
|
-
<td>
|
1130
|
-
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 58</span>
|
1131
|
-
|
1132
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_error identifier id'>error</span>
|
1133
|
-
<span class='rubyid_@errors ivar id'>@errors</span><span class='dot token'>.</span><span class='rubyid_first identifier id'>first</span>
|
1134
|
-
<span class='rubyid_end end kw'>end</span>
|
1135
|
-
</pre>
|
1136
|
-
</td>
|
1137
|
-
</tr>
|
1138
|
-
</table>
|
1139
|
-
</div>
|
1140
|
-
|
1141
|
-
<div class="method_details ">
|
1142
|
-
<h3 class="signature " id="fail?-instance_method">
|
1143
|
-
|
1144
|
-
- (<tt>Boolean</tt>) <strong>fail?</strong>
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
<span class="aliases">Also known as:
|
1149
|
-
<span class="names"><span id='failed?-instance_method'>failed?</span></span>
|
1150
|
-
</span>
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
</h3><div class="docstring">
|
1155
|
-
<div class="discussion">
|
1156
|
-
<p>Returns whether the invocation failed or not.</p>
|
1157
|
-
|
1158
|
-
|
1159
|
-
</div>
|
1160
|
-
</div>
|
1161
|
-
<div class="tags">
|
1162
|
-
|
1163
|
-
<p class="tag_title">Returns:</p>
|
1164
|
-
<ul class="return">
|
1165
|
-
|
1166
|
-
<li>
|
1167
|
-
|
1168
|
-
|
1169
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
—
|
1174
|
-
<div class='inline'><p><code>true</code> if the service invocation failed, <code>false</code> otherwise.</p>
|
1175
|
-
</div>
|
1176
|
-
|
1177
|
-
</li>
|
1178
|
-
|
1179
|
-
</ul>
|
1180
|
-
|
1181
|
-
</div><table class="source_code">
|
1182
|
-
<tr>
|
1183
|
-
<td>
|
1184
|
-
<pre class="lines">
|
1185
|
-
|
1186
|
-
|
1187
|
-
50
|
1188
|
-
51
|
1189
|
-
52</pre>
|
1190
|
-
</td>
|
1191
|
-
<td>
|
1192
|
-
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 50</span>
|
1193
|
-
|
1194
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_fail? fid id'>fail?</span>
|
1195
|
-
<span class='notop op'>!</span><span class='rubyid_@success ivar id'>@success</span>
|
1196
|
-
<span class='rubyid_end end kw'>end</span>
|
1197
|
-
</pre>
|
1198
|
-
</td>
|
1199
|
-
</tr>
|
1200
|
-
</table>
|
1201
|
-
</div>
|
1202
|
-
|
1203
|
-
<div class="method_details ">
|
1204
|
-
<h3 class="signature " id="success?-instance_method">
|
1205
|
-
|
1206
|
-
- (<tt>Boolean</tt>) <strong>success?</strong>
|
1207
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
<span class="aliases">Also known as:
|
1211
|
-
<span class="names"><span id='successful?-instance_method'>successful?</span>, <span id='succeeded?-instance_method'>succeeded?</span></span>
|
1212
|
-
</span>
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
</h3><div class="docstring">
|
1217
|
-
<div class="discussion">
|
1218
|
-
<p>Returns whether the invocation was successful or not.</p>
|
1219
|
-
|
1220
|
-
|
1221
|
-
</div>
|
1222
|
-
</div>
|
1223
|
-
<div class="tags">
|
1224
|
-
|
1225
|
-
<p class="tag_title">Returns:</p>
|
1226
|
-
<ul class="return">
|
1227
|
-
|
1228
|
-
<li>
|
1229
|
-
|
1230
|
-
|
1231
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1235
|
-
—
|
1236
|
-
<div class='inline'><p><code>true</code> if the service invocation was successful, <code>false</code> otherwise.</p>
|
1237
|
-
</div>
|
1238
|
-
|
1239
|
-
</li>
|
1240
|
-
|
1241
|
-
</ul>
|
1242
|
-
|
1243
|
-
</div><table class="source_code">
|
1244
|
-
<tr>
|
1245
|
-
<td>
|
1246
|
-
<pre class="lines">
|
1247
|
-
|
1248
|
-
|
1249
|
-
40
|
1250
|
-
41
|
1251
|
-
42
|
1252
|
-
43</pre>
|
1253
|
-
</td>
|
1254
|
-
<td>
|
1255
|
-
<pre class="code"><span class="info file"># File 'lib/ballast/service.rb', line 40</span>
|
1256
|
-
|
1257
|
-
<span class='rubyid_def def kw'>def</span> <span class='rubyid_success? fid id'>success?</span>
|
1258
|
-
<span class='comment val'># TODO@PI: Ignore rubocop on this</span>
|
1259
|
-
<span class='rubyid_@success ivar id'>@success</span>
|
1260
|
-
<span class='rubyid_end end kw'>end</span>
|
1261
|
-
</pre>
|
1262
|
-
</td>
|
1263
|
-
</tr>
|
1264
|
-
</table>
|
1265
|
-
</div>
|
1266
|
-
|
1267
|
-
</div>
|
1268
|
-
|
1269
|
-
</div>
|
1270
|
-
|
1271
|
-
<div id="footer">
|
1272
|
-
Generated on Tue Mar 29 10:52:51 2016 by
|
1273
|
-
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
1274
|
-
0.8.7.6 (ruby-2.3.0).
|
1275
|
-
</div>
|
1276
|
-
|
1277
|
-
</body>
|
1278
|
-
</html>
|