simple-service 0.1.4
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 +7 -0
- data/.gitignore +12 -0
- data/.rubocop.yml +100 -0
- data/.tm_properties +1 -0
- data/Gemfile +14 -0
- data/Makefile +9 -0
- data/README.md +68 -0
- data/Rakefile +6 -0
- data/VERSION +1 -0
- data/bin/bundle +105 -0
- data/bin/console +15 -0
- data/bin/rake +29 -0
- data/bin/rspec +29 -0
- data/doc/Simple.html +117 -0
- data/doc/Simple/Service.html +863 -0
- data/doc/Simple/Service/Action.html +1014 -0
- data/doc/Simple/Service/Action/Comment.html +451 -0
- data/doc/Simple/Service/Action/Comment/Extractor.html +347 -0
- data/doc/Simple/Service/Action/IndieHash.html +506 -0
- data/doc/Simple/Service/Action/MethodReflection.html +285 -0
- data/doc/Simple/Service/Action/Parameter.html +816 -0
- data/doc/Simple/Service/ArgumentError.html +128 -0
- data/doc/Simple/Service/ClassMethods.html +187 -0
- data/doc/Simple/Service/Context.html +379 -0
- data/doc/Simple/Service/ContextMissingError.html +124 -0
- data/doc/Simple/Service/ContextReadOnlyError.html +206 -0
- data/doc/Simple/Service/ExtraArguments.html +428 -0
- data/doc/Simple/Service/GemHelper.html +190 -0
- data/doc/Simple/Service/MissingArguments.html +426 -0
- data/doc/Simple/Service/NoSuchAction.html +433 -0
- data/doc/_index.html +286 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +496 -0
- data/doc/file.README.html +146 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +146 -0
- data/doc/js/app.js +303 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +539 -0
- data/doc/top-level-namespace.html +110 -0
- data/lib/simple-service.rb +3 -0
- data/lib/simple/service.rb +143 -0
- data/lib/simple/service/action.rb +203 -0
- data/lib/simple/service/action/comment.rb +57 -0
- data/lib/simple/service/action/indie_hash.rb +37 -0
- data/lib/simple/service/action/method_reflection.rb +70 -0
- data/lib/simple/service/action/parameter.rb +42 -0
- data/lib/simple/service/context.rb +94 -0
- data/lib/simple/service/errors.rb +54 -0
- data/lib/simple/service/version.rb +29 -0
- data/log/.gitkeep +0 -0
- data/scripts/release +2 -0
- data/scripts/release.rb +91 -0
- data/scripts/stats +5 -0
- data/scripts/watch +2 -0
- data/simple-service.gemspec +25 -0
- data/spec/simple/service/action_invoke2_spec.rb +166 -0
- data/spec/simple/service/action_invoke_spec.rb +266 -0
- data/spec/simple/service/action_spec.rb +51 -0
- data/spec/simple/service/context_spec.rb +69 -0
- data/spec/simple/service/service_spec.rb +105 -0
- data/spec/simple/service/version_spec.rb +7 -0
- data/spec/spec_helper.rb +38 -0
- data/spec/support/spec_services.rb +50 -0
- metadata +130 -0
@@ -0,0 +1,863 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Module: Simple::Service
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.20
|
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
|
+
pathId = "Simple::Service";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (S)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Simple.html" title="Simple (module)">Simple</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Service</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Module: Simple::Service
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
<dl>
|
80
|
+
<dt>Defined in:</dt>
|
81
|
+
<dd>lib/simple/service.rb<span class="defines">,<br />
|
82
|
+
lib/simple/service/action.rb,<br /> lib/simple/service/action.rb,<br /> lib/simple/service/errors.rb,<br /> lib/simple/service/context.rb,<br /> lib/simple/service/context.rb,<br /> lib/simple/service/version.rb</span>
|
83
|
+
</dd>
|
84
|
+
</dl>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
|
88
|
+
<h2>Overview</h2><div class="docstring">
|
89
|
+
<div class="discussion">
|
90
|
+
|
91
|
+
<p>The <strong>Simple::Service</strong> interface</p>
|
92
|
+
|
93
|
+
<p>This module implements the main API of the Simple::Service ruby gem.</p>
|
94
|
+
<ol><li>
|
95
|
+
<p><em>Marking a service module:</em> To turn a target module as a service module one must include <code>Simple::Service</code> into the target. This serves as a marker that this module is actually intended to provide one or more services. Example:</p>
|
96
|
+
|
97
|
+
<pre class="code ruby"><code class="ruby"><span class='kw'>module</span> <span class='const'>GodMode</span>
|
98
|
+
<span class='id identifier rubyid_include'>include</span> <span class='const'><span class='object_link'><a href="../Simple.html" title="Simple (module)">Simple</a></span></span><span class='op'>::</span><span class='const'>Service</span>
|
99
|
+
|
100
|
+
<span class='comment'># Build a universe.
|
101
|
+
</span> <span class='comment'>#
|
102
|
+
</span> <span class='comment'># This comment will become part of the full description of the
|
103
|
+
</span> <span class='comment'># "build_universe" service
|
104
|
+
</span> <span class='kw'>def</span> <span class='id identifier rubyid_build_universe'>build_universe</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>c:</span> <span class='comma'>,</span> <span class='label'>pi:</span> <span class='float'>3.14</span><span class='comma'>,</span> <span class='label'>e:</span> <span class='float'>2.781</span><span class='rparen'>)</span>
|
105
|
+
<span class='comment'># at this point I realize that *I* am not God.
|
106
|
+
</span>
|
107
|
+
<span class='int'>42</span> <span class='comment'># Best try approach
|
108
|
+
</span> <span class='kw'>end</span>
|
109
|
+
<span class='kw'>end</span>
|
110
|
+
</code></pre>
|
111
|
+
</li><li>
|
112
|
+
<p><em>Discover services:</em> To discover services in a service module use the #actions method. This returns a Hash of actions. [TODO] why a Hash?</p>
|
113
|
+
|
114
|
+
<pre class="code ruby"><code class="ruby">Simple::Service.actions(GodMode)
|
115
|
+
=> {:build_universe=>#<Simple::Service::Action...>, ...}
|
116
|
+
</code></pre>
|
117
|
+
</li><li>
|
118
|
+
<p><em>Invoke a service:</em> run <code>Simple::Service.invoke</code> or <code>Simple::Service.invoke2</code>. You must set a context first. </p>
|
119
|
+
|
120
|
+
<pre class="code ruby"><code class="ruby">Simple::Service.with_context do
|
121
|
+
Simple::Service.invoke(GodMode, :build_universe, "TestWorld", c: 1e9)
|
122
|
+
end
|
123
|
+
=> 42
|
124
|
+
</code></pre>
|
125
|
+
</li></ol>
|
126
|
+
|
127
|
+
|
128
|
+
</div>
|
129
|
+
</div>
|
130
|
+
<div class="tags">
|
131
|
+
|
132
|
+
|
133
|
+
</div><h2>Defined Under Namespace</h2>
|
134
|
+
<p class="children">
|
135
|
+
|
136
|
+
|
137
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Service/ClassMethods.html" title="Simple::Service::ClassMethods (module)">ClassMethods</a></span>, <span class='object_link'><a href="Service/GemHelper.html" title="Simple::Service::GemHelper (module)">GemHelper</a></span>
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Service/Action.html" title="Simple::Service::Action (class)">Action</a></span>, <span class='object_link'><a href="Service/ArgumentError.html" title="Simple::Service::ArgumentError (class)">ArgumentError</a></span>, <span class='object_link'><a href="Service/Context.html" title="Simple::Service::Context (class)">Context</a></span>, <span class='object_link'><a href="Service/ContextMissingError.html" title="Simple::Service::ContextMissingError (class)">ContextMissingError</a></span>, <span class='object_link'><a href="Service/ContextReadOnlyError.html" title="Simple::Service::ContextReadOnlyError (class)">ContextReadOnlyError</a></span>, <span class='object_link'><a href="Service/ExtraArguments.html" title="Simple::Service::ExtraArguments (class)">ExtraArguments</a></span>, <span class='object_link'><a href="Service/MissingArguments.html" title="Simple::Service::MissingArguments (class)">MissingArguments</a></span>, <span class='object_link'><a href="Service/NoSuchAction.html" title="Simple::Service::NoSuchAction (class)">NoSuchAction</a></span>
|
142
|
+
|
143
|
+
|
144
|
+
</p>
|
145
|
+
|
146
|
+
|
147
|
+
<h2>
|
148
|
+
Constant Summary
|
149
|
+
<small><a href="#" class="constants_summary_toggle">collapse</a></small>
|
150
|
+
</h2>
|
151
|
+
|
152
|
+
<dl class="constants">
|
153
|
+
|
154
|
+
<dt id="VERSION-constant" class="">VERSION =
|
155
|
+
|
156
|
+
</dt>
|
157
|
+
<dd><pre class="code"><span class='const'><span class='object_link'><a href="Service/GemHelper.html" title="Simple::Service::GemHelper (module)">GemHelper</a></span></span><span class='period'>.</span><span class='id identifier rubyid_version'><span class='object_link'><a href="Service/GemHelper.html#version-instance_method" title="Simple::Service::GemHelper#version (method)">version</a></span></span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>simple-service</span><span class='tstring_end'>"</span></span></pre></dd>
|
158
|
+
|
159
|
+
</dl>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
<h2>
|
170
|
+
Class Method Summary
|
171
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
172
|
+
</h2>
|
173
|
+
|
174
|
+
<ul class="summary">
|
175
|
+
|
176
|
+
<li class="public ">
|
177
|
+
<span class="summary_signature">
|
178
|
+
|
179
|
+
<a href="#action-class_method" title="action (class method)">.<strong>action</strong>(service, name) ⇒ Object </a>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
</span>
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<span class="summary_desc"><div class='inline'>
|
194
|
+
<p>returns the action with the given name.</p>
|
195
|
+
</div></span>
|
196
|
+
|
197
|
+
</li>
|
198
|
+
|
199
|
+
|
200
|
+
<li class="public ">
|
201
|
+
<span class="summary_signature">
|
202
|
+
|
203
|
+
<a href="#actions-class_method" title="actions (class method)">.<strong>actions</strong>(service) ⇒ Object </a>
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
</span>
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<span class="summary_desc"><div class='inline'>
|
218
|
+
<p>returns a Hash with all actions in the <code>service</code> module.</p>
|
219
|
+
</div></span>
|
220
|
+
|
221
|
+
</li>
|
222
|
+
|
223
|
+
|
224
|
+
<li class="public ">
|
225
|
+
<span class="summary_signature">
|
226
|
+
|
227
|
+
<a href="#context-class_method" title="context (class method)">.<strong>context</strong> ⇒ Object </a>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
</span>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
<span class="summary_desc"><div class='inline'>
|
242
|
+
<p>Returns the current context.</p>
|
243
|
+
</div></span>
|
244
|
+
|
245
|
+
</li>
|
246
|
+
|
247
|
+
|
248
|
+
<li class="public ">
|
249
|
+
<span class="summary_signature">
|
250
|
+
|
251
|
+
<a href="#included-class_method" title="included (class method)">.<strong>included</strong>(klass) ⇒ Object </a>
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
</span>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
266
|
+
|
267
|
+
</li>
|
268
|
+
|
269
|
+
|
270
|
+
<li class="public ">
|
271
|
+
<span class="summary_signature">
|
272
|
+
|
273
|
+
<a href="#invoke-class_method" title="invoke (class method)">.<strong>invoke</strong>(service, name, *args, **named_args) ⇒ Object </a>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
</span>
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
<span class="summary_desc"><div class='inline'>
|
288
|
+
<p>invokes an action with a given <code>name</code> in a service with <code>arguments</code> and <code>params</code>.</p>
|
289
|
+
</div></span>
|
290
|
+
|
291
|
+
</li>
|
292
|
+
|
293
|
+
|
294
|
+
<li class="public ">
|
295
|
+
<span class="summary_signature">
|
296
|
+
|
297
|
+
<a href="#invoke2-class_method" title="invoke2 (class method)">.<strong>invoke2</strong>(service, name, args: {}, flags: {}) ⇒ Object </a>
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
</span>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
<span class="summary_desc"><div class='inline'>
|
312
|
+
<p>invokes an action with a given <code>name</code> in a service with a Hash of arguments.</p>
|
313
|
+
</div></span>
|
314
|
+
|
315
|
+
</li>
|
316
|
+
|
317
|
+
|
318
|
+
<li class="public ">
|
319
|
+
<span class="summary_signature">
|
320
|
+
|
321
|
+
<a href="#service%3F-class_method" title="service? (class method)">.<strong>service?</strong>(service) ⇒ Boolean </a>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
</span>
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
<span class="summary_desc"><div class='inline'>
|
336
|
+
<p>returns true if the passed in object is a service module.</p>
|
337
|
+
</div></span>
|
338
|
+
|
339
|
+
</li>
|
340
|
+
|
341
|
+
|
342
|
+
<li class="public ">
|
343
|
+
<span class="summary_signature">
|
344
|
+
|
345
|
+
<a href="#verify_service!-class_method" title="verify_service! (class method)">.<strong>verify_service!</strong>(service) ⇒ Object </a>
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
</span>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
|
359
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
360
|
+
|
361
|
+
</li>
|
362
|
+
|
363
|
+
|
364
|
+
<li class="public ">
|
365
|
+
<span class="summary_signature">
|
366
|
+
|
367
|
+
<a href="#with_context-class_method" title="with_context (class method)">.<strong>with_context</strong>(ctx = nil, &block) ⇒ Object </a>
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
</span>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
<span class="summary_desc"><div class='inline'>
|
382
|
+
<p>yields a block with a given context, and restores the previous context object afterwards.</p>
|
383
|
+
</div></span>
|
384
|
+
|
385
|
+
</li>
|
386
|
+
|
387
|
+
|
388
|
+
</ul>
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
<div id="class_method_details" class="method_details_list">
|
394
|
+
<h2>Class Method Details</h2>
|
395
|
+
|
396
|
+
|
397
|
+
<div class="method_details first">
|
398
|
+
<h3 class="signature first" id="action-class_method">
|
399
|
+
|
400
|
+
.<strong>action</strong>(service, name) ⇒ <tt>Object</tt>
|
401
|
+
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
</h3><div class="docstring">
|
407
|
+
<div class="discussion">
|
408
|
+
|
409
|
+
<p>returns the action with the given name.</p>
|
410
|
+
|
411
|
+
|
412
|
+
</div>
|
413
|
+
</div>
|
414
|
+
<div class="tags">
|
415
|
+
|
416
|
+
|
417
|
+
</div><table class="source_code">
|
418
|
+
<tr>
|
419
|
+
<td>
|
420
|
+
<pre class="lines">
|
421
|
+
|
422
|
+
|
423
|
+
69
|
424
|
+
70
|
425
|
+
71
|
426
|
+
72
|
427
|
+
73
|
428
|
+
74</pre>
|
429
|
+
</td>
|
430
|
+
<td>
|
431
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 69</span>
|
432
|
+
|
433
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_action'>action</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
434
|
+
<span class='id identifier rubyid_actions'>actions</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_actions'>actions</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
435
|
+
<span class='id identifier rubyid_actions'>actions</span><span class='lbracket'>[</span><span class='id identifier rubyid_name'>name</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='kw'>begin</span>
|
436
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'><span class='object_link'><a href="../Simple.html" title="Simple (module)">Simple</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="" title="Simple::Service (module)">Service</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Service/NoSuchAction.html" title="Simple::Service::NoSuchAction (class)">NoSuchAction</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Service/NoSuchAction.html#initialize-instance_method" title="Simple::Service::NoSuchAction#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
437
|
+
<span class='kw'>end</span>
|
438
|
+
<span class='kw'>end</span></pre>
|
439
|
+
</td>
|
440
|
+
</tr>
|
441
|
+
</table>
|
442
|
+
</div>
|
443
|
+
|
444
|
+
<div class="method_details ">
|
445
|
+
<h3 class="signature " id="actions-class_method">
|
446
|
+
|
447
|
+
.<strong>actions</strong>(service) ⇒ <tt>Object</tt>
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
</h3><div class="docstring">
|
454
|
+
<div class="discussion">
|
455
|
+
|
456
|
+
<p>returns a Hash with all actions in the <code>service</code> module</p>
|
457
|
+
|
458
|
+
|
459
|
+
</div>
|
460
|
+
</div>
|
461
|
+
<div class="tags">
|
462
|
+
|
463
|
+
|
464
|
+
</div><table class="source_code">
|
465
|
+
<tr>
|
466
|
+
<td>
|
467
|
+
<pre class="lines">
|
468
|
+
|
469
|
+
|
470
|
+
62
|
471
|
+
63
|
472
|
+
64
|
473
|
+
65
|
474
|
+
66</pre>
|
475
|
+
</td>
|
476
|
+
<td>
|
477
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 62</span>
|
478
|
+
|
479
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_actions'>actions</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
480
|
+
<span class='id identifier rubyid_verify_service!'>verify_service!</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
481
|
+
|
482
|
+
<span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid___simple_service_actions__'>__simple_service_actions__</span>
|
483
|
+
<span class='kw'>end</span></pre>
|
484
|
+
</td>
|
485
|
+
</tr>
|
486
|
+
</table>
|
487
|
+
</div>
|
488
|
+
|
489
|
+
<div class="method_details ">
|
490
|
+
<h3 class="signature " id="context-class_method">
|
491
|
+
|
492
|
+
.<strong>context</strong> ⇒ <tt>Object</tt>
|
493
|
+
|
494
|
+
|
495
|
+
|
496
|
+
|
497
|
+
|
498
|
+
</h3><div class="docstring">
|
499
|
+
<div class="discussion">
|
500
|
+
|
501
|
+
<p>Returns the current context.</p>
|
502
|
+
|
503
|
+
|
504
|
+
</div>
|
505
|
+
</div>
|
506
|
+
<div class="tags">
|
507
|
+
|
508
|
+
|
509
|
+
</div><table class="source_code">
|
510
|
+
<tr>
|
511
|
+
<td>
|
512
|
+
<pre class="lines">
|
513
|
+
|
514
|
+
|
515
|
+
3
|
516
|
+
4
|
517
|
+
5</pre>
|
518
|
+
</td>
|
519
|
+
<td>
|
520
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service/context.rb', line 3</span>
|
521
|
+
|
522
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_context'>context</span>
|
523
|
+
<span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:"Simple::Service.context"</span><span class='rbracket'>]</span>
|
524
|
+
<span class='kw'>end</span></pre>
|
525
|
+
</td>
|
526
|
+
</tr>
|
527
|
+
</table>
|
528
|
+
</div>
|
529
|
+
|
530
|
+
<div class="method_details ">
|
531
|
+
<h3 class="signature " id="included-class_method">
|
532
|
+
|
533
|
+
.<strong>included</strong>(klass) ⇒ <tt>Object</tt>
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
</h3><table class="source_code">
|
540
|
+
<tr>
|
541
|
+
<td>
|
542
|
+
<pre class="lines">
|
543
|
+
|
544
|
+
|
545
|
+
47
|
546
|
+
48
|
547
|
+
49</pre>
|
548
|
+
</td>
|
549
|
+
<td>
|
550
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 47</span>
|
551
|
+
|
552
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_included'>included</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='rparen'>)</span> <span class='comment'># @private
|
553
|
+
</span> <span class='id identifier rubyid_klass'>klass</span><span class='period'>.</span><span class='id identifier rubyid_extend'>extend</span> <span class='const'><span class='object_link'><a href="Service/ClassMethods.html" title="Simple::Service::ClassMethods (module)">ClassMethods</a></span></span>
|
554
|
+
<span class='kw'>end</span></pre>
|
555
|
+
</td>
|
556
|
+
</tr>
|
557
|
+
</table>
|
558
|
+
</div>
|
559
|
+
|
560
|
+
<div class="method_details ">
|
561
|
+
<h3 class="signature " id="invoke-class_method">
|
562
|
+
|
563
|
+
.<strong>invoke</strong>(service, name, *args, **named_args) ⇒ <tt>Object</tt>
|
564
|
+
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
</h3><div class="docstring">
|
570
|
+
<div class="discussion">
|
571
|
+
|
572
|
+
<p>invokes an action with a given <code>name</code> in a service with <code>arguments</code> and <code>params</code>.</p>
|
573
|
+
|
574
|
+
<p>You cannot call this method if the context is not set.</p>
|
575
|
+
|
576
|
+
<p>When calling #invoke using positional arguments they will be matched against positional arguments of the invoked method - but they will not be matched against named arguments.</p>
|
577
|
+
|
578
|
+
<p>When there are not enough positional arguments to match the number of required positional arguments of the method we raise an ArgumentError.</p>
|
579
|
+
|
580
|
+
<p>When there are more positional arguments provided than the number accepted by the method we raise an ArgumentError.</p>
|
581
|
+
|
582
|
+
<p>Entries in the named_args Hash that are not defined in the action itself are ignored.</p>
|
583
|
+
|
584
|
+
|
585
|
+
</div>
|
586
|
+
</div>
|
587
|
+
<div class="tags">
|
588
|
+
|
589
|
+
<p class="tag_title">Raises:</p>
|
590
|
+
<ul class="raise">
|
591
|
+
|
592
|
+
<li>
|
593
|
+
|
594
|
+
|
595
|
+
<span class='type'>(<tt><span class='object_link'><a href="Service/ContextMissingError.html" title="Simple::Service::ContextMissingError (class)">ContextMissingError</a></span></tt>)</span>
|
596
|
+
|
597
|
+
|
598
|
+
|
599
|
+
</li>
|
600
|
+
|
601
|
+
</ul>
|
602
|
+
|
603
|
+
</div><table class="source_code">
|
604
|
+
<tr>
|
605
|
+
<td>
|
606
|
+
<pre class="lines">
|
607
|
+
|
608
|
+
|
609
|
+
91
|
610
|
+
92
|
611
|
+
93
|
612
|
+
94
|
613
|
+
95</pre>
|
614
|
+
</td>
|
615
|
+
<td>
|
616
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 91</span>
|
617
|
+
|
618
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_named_args'>named_args</span><span class='rparen'>)</span>
|
619
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Service/ContextMissingError.html" title="Simple::Service::ContextMissingError (class)">ContextMissingError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Need to set context before calling ::Simple::Service.invoke</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_context'>context</span>
|
620
|
+
|
621
|
+
<span class='id identifier rubyid_action'>action</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_invoke'>invoke</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_named_args'>named_args</span><span class='rparen'>)</span>
|
622
|
+
<span class='kw'>end</span></pre>
|
623
|
+
</td>
|
624
|
+
</tr>
|
625
|
+
</table>
|
626
|
+
</div>
|
627
|
+
|
628
|
+
<div class="method_details ">
|
629
|
+
<h3 class="signature " id="invoke2-class_method">
|
630
|
+
|
631
|
+
.<strong>invoke2</strong>(service, name, args: {}, flags: {}) ⇒ <tt>Object</tt>
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
|
636
|
+
|
637
|
+
</h3><div class="docstring">
|
638
|
+
<div class="discussion">
|
639
|
+
|
640
|
+
<p>invokes an action with a given <code>name</code> in a service with a Hash of arguments.</p>
|
641
|
+
|
642
|
+
<p>You cannot call this method if the context is not set.</p>
|
643
|
+
|
644
|
+
|
645
|
+
</div>
|
646
|
+
</div>
|
647
|
+
<div class="tags">
|
648
|
+
|
649
|
+
<p class="tag_title">Raises:</p>
|
650
|
+
<ul class="raise">
|
651
|
+
|
652
|
+
<li>
|
653
|
+
|
654
|
+
|
655
|
+
<span class='type'>(<tt><span class='object_link'><a href="Service/ContextMissingError.html" title="Simple::Service::ContextMissingError (class)">ContextMissingError</a></span></tt>)</span>
|
656
|
+
|
657
|
+
|
658
|
+
|
659
|
+
</li>
|
660
|
+
|
661
|
+
</ul>
|
662
|
+
|
663
|
+
</div><table class="source_code">
|
664
|
+
<tr>
|
665
|
+
<td>
|
666
|
+
<pre class="lines">
|
667
|
+
|
668
|
+
|
669
|
+
100
|
670
|
+
101
|
671
|
+
102
|
672
|
+
103
|
673
|
+
104</pre>
|
674
|
+
</td>
|
675
|
+
<td>
|
676
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 100</span>
|
677
|
+
|
678
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_invoke2'>invoke2</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='label'>args:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='comma'>,</span> <span class='label'>flags:</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
|
679
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'><span class='object_link'><a href="Service/ContextMissingError.html" title="Simple::Service::ContextMissingError (class)">ContextMissingError</a></span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Need to set context before calling ::Simple::Service.invoke</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_context'>context</span>
|
680
|
+
|
681
|
+
<span class='id identifier rubyid_action'>action</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_invoke2'>invoke2</span><span class='lparen'>(</span><span class='label'>args:</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='label'>flags:</span> <span class='id identifier rubyid_flags'>flags</span><span class='rparen'>)</span>
|
682
|
+
<span class='kw'>end</span></pre>
|
683
|
+
</td>
|
684
|
+
</tr>
|
685
|
+
</table>
|
686
|
+
</div>
|
687
|
+
|
688
|
+
<div class="method_details ">
|
689
|
+
<h3 class="signature " id="service?-class_method">
|
690
|
+
|
691
|
+
.<strong>service?</strong>(service) ⇒ <tt>Boolean</tt>
|
692
|
+
|
693
|
+
|
694
|
+
|
695
|
+
|
696
|
+
|
697
|
+
</h3><div class="docstring">
|
698
|
+
<div class="discussion">
|
699
|
+
|
700
|
+
<p>returns true if the passed in object is a service module.</p>
|
701
|
+
|
702
|
+
|
703
|
+
</div>
|
704
|
+
</div>
|
705
|
+
<div class="tags">
|
706
|
+
|
707
|
+
<p class="tag_title">Returns:</p>
|
708
|
+
<ul class="return">
|
709
|
+
|
710
|
+
<li>
|
711
|
+
|
712
|
+
|
713
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
</li>
|
718
|
+
|
719
|
+
</ul>
|
720
|
+
|
721
|
+
</div><table class="source_code">
|
722
|
+
<tr>
|
723
|
+
<td>
|
724
|
+
<pre class="lines">
|
725
|
+
|
726
|
+
|
727
|
+
52
|
728
|
+
53
|
729
|
+
54</pre>
|
730
|
+
</td>
|
731
|
+
<td>
|
732
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 52</span>
|
733
|
+
|
734
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_service?'>service?</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
735
|
+
<span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Module</span><span class='rparen'>)</span> <span class='op'>&&</span> <span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='kw'>self</span><span class='rparen'>)</span>
|
736
|
+
<span class='kw'>end</span></pre>
|
737
|
+
</td>
|
738
|
+
</tr>
|
739
|
+
</table>
|
740
|
+
</div>
|
741
|
+
|
742
|
+
<div class="method_details ">
|
743
|
+
<h3 class="signature " id="verify_service!-class_method">
|
744
|
+
|
745
|
+
.<strong>verify_service!</strong>(service) ⇒ <tt>Object</tt>
|
746
|
+
|
747
|
+
|
748
|
+
|
749
|
+
|
750
|
+
|
751
|
+
</h3><div class="docstring">
|
752
|
+
<div class="discussion">
|
753
|
+
|
754
|
+
|
755
|
+
</div>
|
756
|
+
</div>
|
757
|
+
<div class="tags">
|
758
|
+
|
759
|
+
<p class="tag_title">Raises:</p>
|
760
|
+
<ul class="raise">
|
761
|
+
|
762
|
+
<li>
|
763
|
+
|
764
|
+
|
765
|
+
<span class='type'>(<tt>::ArgumentError</tt>)</span>
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
</li>
|
770
|
+
|
771
|
+
</ul>
|
772
|
+
|
773
|
+
</div><table class="source_code">
|
774
|
+
<tr>
|
775
|
+
<td>
|
776
|
+
<pre class="lines">
|
777
|
+
|
778
|
+
|
779
|
+
56
|
780
|
+
57
|
781
|
+
58
|
782
|
+
59</pre>
|
783
|
+
</td>
|
784
|
+
<td>
|
785
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service.rb', line 56</span>
|
786
|
+
|
787
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_verify_service!'>verify_service!</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span> <span class='comment'># @private
|
788
|
+
</span> <span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> must be a Simple::Service, but is not even a Module</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Module</span><span class='rparen'>)</span>
|
789
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='op'>::</span><span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_service'>service</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> must be a Simple::Service, did you 'include Simple::Service'</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_service?'>service?</span><span class='lparen'>(</span><span class='id identifier rubyid_service'>service</span><span class='rparen'>)</span>
|
790
|
+
<span class='kw'>end</span></pre>
|
791
|
+
</td>
|
792
|
+
</tr>
|
793
|
+
</table>
|
794
|
+
</div>
|
795
|
+
|
796
|
+
<div class="method_details ">
|
797
|
+
<h3 class="signature " id="with_context-class_method">
|
798
|
+
|
799
|
+
.<strong>with_context</strong>(ctx = nil, &block) ⇒ <tt>Object</tt>
|
800
|
+
|
801
|
+
|
802
|
+
|
803
|
+
|
804
|
+
|
805
|
+
</h3><div class="docstring">
|
806
|
+
<div class="discussion">
|
807
|
+
|
808
|
+
<p>yields a block with a given context, and restores the previous context object afterwards.</p>
|
809
|
+
|
810
|
+
|
811
|
+
</div>
|
812
|
+
</div>
|
813
|
+
<div class="tags">
|
814
|
+
|
815
|
+
|
816
|
+
</div><table class="source_code">
|
817
|
+
<tr>
|
818
|
+
<td>
|
819
|
+
<pre class="lines">
|
820
|
+
|
821
|
+
|
822
|
+
9
|
823
|
+
10
|
824
|
+
11
|
825
|
+
12
|
826
|
+
13
|
827
|
+
14
|
828
|
+
15
|
829
|
+
16
|
830
|
+
17
|
831
|
+
18</pre>
|
832
|
+
</td>
|
833
|
+
<td>
|
834
|
+
<pre class="code"><span class="info file"># File 'lib/simple/service/context.rb', line 9</span>
|
835
|
+
|
836
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_with_context'>with_context</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
837
|
+
<span class='id identifier rubyid_old_ctx'>old_ctx</span> <span class='op'>=</span> <span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:"Simple::Service.context"</span><span class='rbracket'>]</span>
|
838
|
+
<span class='id identifier rubyid_new_ctx'>new_ctx</span> <span class='op'>=</span> <span class='id identifier rubyid_old_ctx'>old_ctx</span> <span class='op'>?</span> <span class='id identifier rubyid_old_ctx'>old_ctx</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span> <span class='op'>:</span> <span class='const'><span class='object_link'><a href="Service/Context.html" title="Simple::Service::Context (class)">Context</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Service/Context.html#initialize-instance_method" title="Simple::Service::Context#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_ctx'>ctx</span><span class='rparen'>)</span>
|
839
|
+
|
840
|
+
<span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:"Simple::Service.context"</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_new_ctx'>new_ctx</span>
|
841
|
+
|
842
|
+
<span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
843
|
+
<span class='kw'>ensure</span>
|
844
|
+
<span class='const'>Thread</span><span class='period'>.</span><span class='id identifier rubyid_current'>current</span><span class='lbracket'>[</span><span class='symbol'>:"Simple::Service.context"</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_old_ctx'>old_ctx</span>
|
845
|
+
<span class='kw'>end</span></pre>
|
846
|
+
</td>
|
847
|
+
</tr>
|
848
|
+
</table>
|
849
|
+
</div>
|
850
|
+
|
851
|
+
</div>
|
852
|
+
|
853
|
+
</div>
|
854
|
+
|
855
|
+
<div id="footer">
|
856
|
+
Generated on Tue Dec 3 13:46:26 2019 by
|
857
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
858
|
+
0.9.20 (ruby-2.5.1).
|
859
|
+
</div>
|
860
|
+
|
861
|
+
</div>
|
862
|
+
</body>
|
863
|
+
</html>
|