tango-etl 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/{changelog.md → CHANGELOG.md} +5 -1
- data/{readme.md → README.md} +1 -1
- data/doc/Multidb/Balancer.html +202 -0
- data/doc/Multidb.html +184 -0
- data/doc/Tango/AbstractModel.html +608 -0
- data/doc/Tango/App.html +1334 -0
- data/doc/Tango/DatabaseLocker.html +541 -0
- data/doc/Tango/ETL/Dispatcher.html +465 -0
- data/doc/Tango/ETL/HandlerInterface.html +639 -0
- data/doc/Tango/ETL/OperatorInterface.html +494 -0
- data/doc/Tango/ETL.html +117 -0
- data/doc/Tango/Kernel.html +432 -0
- data/doc/Tango/LinkStack.html +737 -0
- data/doc/Tango/Resource/Buffer.html +565 -0
- data/doc/Tango/Resource/Cache.html +834 -0
- data/doc/Tango/Resource.html +117 -0
- data/doc/Tango.html +131 -0
- data/doc/_index.html +297 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +339 -0
- data/doc/file.README.html +80 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +26 -0
- data/doc/index.html +80 -0
- data/doc/js/app.js +219 -0
- data/doc/js/full_list.js +178 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +365 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/tango/abstract_model.rb +1 -0
- data/lib/tango/app.rb +4 -7
- data/lib/tango/database_locker.rb +23 -2
- data/lib/tango/etl/handler_interface.rb +12 -6
- data/lib/tango/resource/buffer.rb +7 -7
- data/lib/tango/resource/cache.rb +18 -13
- data/lib/tango/version.rb +1 -1
- data/test/support/lib/simple_handler.rb +5 -14
- data/test/unit/etl/test_dispatcher.rb +21 -5
- metadata +33 -6
- data/config/app.yml.sample +0 -6
- data/config/database.yml.sample +0 -27
@@ -0,0 +1,834 @@
|
|
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: Tango::Resource::Cache
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.7.4
|
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#!Tango/Resource/Cache.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 (C)</a> »
|
35
|
+
<span class='title'><span class='object_link'><a href="../../Tango.html" title="Tango (module)">Tango</a></span></span> » <span class='title'><span class='object_link'><a href="../Resource.html" title="Tango::Resource (module)">Resource</a></span></span>
|
36
|
+
»
|
37
|
+
<span class="title">Cache</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: Tango::Resource::Cache
|
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">Tango::Resource::Cache</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/tango/resource/cache.rb</dd>
|
98
|
+
|
99
|
+
</dl>
|
100
|
+
<div class="clear"></div>
|
101
|
+
|
102
|
+
<h2>Overview</h2><div class="docstring">
|
103
|
+
<div class="discussion">
|
104
|
+
|
105
|
+
<p>Key - value caching system for resources</p>
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
<p class="tag_title">Author:</p>
|
113
|
+
<ul class="author">
|
114
|
+
|
115
|
+
<li>
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
<div class='inline'>
|
122
|
+
<p>Mckomo</p>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
</li>
|
126
|
+
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
</div>
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
134
|
+
<ul class="summary">
|
135
|
+
|
136
|
+
<li class="public ">
|
137
|
+
<span class="summary_signature">
|
138
|
+
|
139
|
+
<a href="#buffer-instance_method" title="#buffer (instance method)">- (Object) <strong>buffer</strong> </a>
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
</span>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
<span class="note title readonly">readonly</span>
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
<span class="summary_desc"><div class='inline'>
|
159
|
+
<p>Returns the value of attribute buffer.</p>
|
160
|
+
</div></span>
|
161
|
+
|
162
|
+
</li>
|
163
|
+
|
164
|
+
|
165
|
+
</ul>
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<h2>
|
172
|
+
Instance Method Summary
|
173
|
+
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
|
174
|
+
</h2>
|
175
|
+
|
176
|
+
<ul class="summary">
|
177
|
+
|
178
|
+
<li class="public ">
|
179
|
+
<span class="summary_signature">
|
180
|
+
|
181
|
+
<a href="#get-instance_method" title="#get (instance method)">- (Object) <strong>get</strong>(type, resource) </a>
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
</span>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
<span class="summary_desc"><div class='inline'>
|
196
|
+
<p>Getter for the cache storage.</p>
|
197
|
+
</div></span>
|
198
|
+
|
199
|
+
</li>
|
200
|
+
|
201
|
+
|
202
|
+
<li class="public ">
|
203
|
+
<span class="summary_signature">
|
204
|
+
|
205
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">- (Tango::Resources::Cache) <strong>initialize</strong>(buffer = nil) </a>
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
</span>
|
210
|
+
|
211
|
+
|
212
|
+
<span class="note title constructor">constructor</span>
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
<span class="summary_desc"><div class='inline'>
|
222
|
+
<p>Constructor of the Cache.</p>
|
223
|
+
</div></span>
|
224
|
+
|
225
|
+
</li>
|
226
|
+
|
227
|
+
|
228
|
+
<li class="public ">
|
229
|
+
<span class="summary_signature">
|
230
|
+
|
231
|
+
<a href="#load-instance_method" title="#load (instance method)">- (Object) <strong>load</strong>(type, resource) </a>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
</span>
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
<span class="summary_desc"><div class='inline'>
|
246
|
+
<p>Get a cached resource or use given block to obtain resource and return it.</p>
|
247
|
+
</div></span>
|
248
|
+
|
249
|
+
</li>
|
250
|
+
|
251
|
+
|
252
|
+
<li class="public ">
|
253
|
+
<span class="summary_signature">
|
254
|
+
|
255
|
+
<a href="#register-instance_method" title="#register (instance method)">- (Tango::Resource::Cache) <strong>register</strong>(type, &release_callback) </a>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
</span>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
|
268
|
+
|
269
|
+
<span class="summary_desc"><div class='inline'>
|
270
|
+
<p>Register new type of resource to be cached.</p>
|
271
|
+
</div></span>
|
272
|
+
|
273
|
+
</li>
|
274
|
+
|
275
|
+
|
276
|
+
<li class="public ">
|
277
|
+
<span class="summary_signature">
|
278
|
+
|
279
|
+
<a href="#set-instance_method" title="#set (instance method)">- (Object) <strong>set</strong>(type, resource) </a>
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
</span>
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
<span class="summary_desc"><div class='inline'>
|
294
|
+
<p>Setter for the cache storage.</p>
|
295
|
+
</div></span>
|
296
|
+
|
297
|
+
</li>
|
298
|
+
|
299
|
+
|
300
|
+
</ul>
|
301
|
+
|
302
|
+
|
303
|
+
<div id="constructor_details" class="method_details_list">
|
304
|
+
<h2>Constructor Details</h2>
|
305
|
+
|
306
|
+
<div class="method_details first">
|
307
|
+
<h3 class="signature first" id="initialize-instance_method">
|
308
|
+
|
309
|
+
- (<tt>Tango::Resources::Cache</tt>) <strong>initialize</strong>(buffer = nil)
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
</h3><div class="docstring">
|
316
|
+
<div class="discussion">
|
317
|
+
|
318
|
+
<p>Constructor of the Cache</p>
|
319
|
+
|
320
|
+
|
321
|
+
</div>
|
322
|
+
</div>
|
323
|
+
<div class="tags">
|
324
|
+
<p class="tag_title">Parameters:</p>
|
325
|
+
<ul class="param">
|
326
|
+
|
327
|
+
<li>
|
328
|
+
|
329
|
+
<span class='name'>buffer</span>
|
330
|
+
|
331
|
+
|
332
|
+
<span class='type'>(<tt>Tango::Resources::Buffer</tt>)</span>
|
333
|
+
|
334
|
+
|
335
|
+
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
336
|
+
|
337
|
+
|
338
|
+
</li>
|
339
|
+
|
340
|
+
</ul>
|
341
|
+
|
342
|
+
|
343
|
+
</div><table class="source_code">
|
344
|
+
<tr>
|
345
|
+
<td>
|
346
|
+
<pre class="lines">
|
347
|
+
|
348
|
+
|
349
|
+
15
|
350
|
+
16
|
351
|
+
17
|
352
|
+
18
|
353
|
+
19
|
354
|
+
20</pre>
|
355
|
+
</td>
|
356
|
+
<td>
|
357
|
+
<pre class="code"><span class="info file"># File 'lib/tango/resource/cache.rb', line 15</span>
|
358
|
+
|
359
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span> <span class='id identifier rubyid_buffer'>buffer</span> <span class='op'>=</span> <span class='kw'>nil</span> <span class='rparen'>)</span>
|
360
|
+
<span class='comment'># Set dependencies
|
361
|
+
</span> <span class='ivar'>@buffer</span> <span class='op'>=</span> <span class='id identifier rubyid_buffer'>buffer</span> <span class='op'>||</span> <span class='const'>Buffer</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
362
|
+
<span class='comment'># Container for resources cache
|
363
|
+
</span> <span class='ivar'>@storage</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
364
|
+
<span class='kw'>end</span></pre>
|
365
|
+
</td>
|
366
|
+
</tr>
|
367
|
+
</table>
|
368
|
+
</div>
|
369
|
+
|
370
|
+
</div>
|
371
|
+
|
372
|
+
<div id="instance_attr_details" class="attr_details">
|
373
|
+
<h2>Instance Attribute Details</h2>
|
374
|
+
|
375
|
+
|
376
|
+
<span id=""></span>
|
377
|
+
<div class="method_details first">
|
378
|
+
<h3 class="signature first" id="buffer-instance_method">
|
379
|
+
|
380
|
+
- (<tt>Object</tt>) <strong>buffer</strong> <span class="extras">(readonly)</span>
|
381
|
+
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
</h3><div class="docstring">
|
387
|
+
<div class="discussion">
|
388
|
+
|
389
|
+
<p>Returns the value of attribute buffer</p>
|
390
|
+
|
391
|
+
|
392
|
+
</div>
|
393
|
+
</div>
|
394
|
+
<div class="tags">
|
395
|
+
|
396
|
+
|
397
|
+
</div><table class="source_code">
|
398
|
+
<tr>
|
399
|
+
<td>
|
400
|
+
<pre class="lines">
|
401
|
+
|
402
|
+
|
403
|
+
9
|
404
|
+
10
|
405
|
+
11</pre>
|
406
|
+
</td>
|
407
|
+
<td>
|
408
|
+
<pre class="code"><span class="info file"># File 'lib/tango/resource/cache.rb', line 9</span>
|
409
|
+
|
410
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_buffer'>buffer</span>
|
411
|
+
<span class='ivar'>@buffer</span>
|
412
|
+
<span class='kw'>end</span></pre>
|
413
|
+
</td>
|
414
|
+
</tr>
|
415
|
+
</table>
|
416
|
+
</div>
|
417
|
+
|
418
|
+
</div>
|
419
|
+
|
420
|
+
|
421
|
+
<div id="instance_method_details" class="method_details_list">
|
422
|
+
<h2>Instance Method Details</h2>
|
423
|
+
|
424
|
+
|
425
|
+
<div class="method_details first">
|
426
|
+
<h3 class="signature first" id="get-instance_method">
|
427
|
+
|
428
|
+
- (<tt>Object</tt>) <strong>get</strong>(type, resource)
|
429
|
+
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
|
434
|
+
</h3><div class="docstring">
|
435
|
+
<div class="discussion">
|
436
|
+
|
437
|
+
<p>Getter for the cache storage</p>
|
438
|
+
|
439
|
+
|
440
|
+
</div>
|
441
|
+
</div>
|
442
|
+
<div class="tags">
|
443
|
+
<p class="tag_title">Parameters:</p>
|
444
|
+
<ul class="param">
|
445
|
+
|
446
|
+
<li>
|
447
|
+
|
448
|
+
<span class='name'>type</span>
|
449
|
+
|
450
|
+
|
451
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
452
|
+
|
453
|
+
|
454
|
+
|
455
|
+
</li>
|
456
|
+
|
457
|
+
<li>
|
458
|
+
|
459
|
+
<span class='name'>key</span>
|
460
|
+
|
461
|
+
|
462
|
+
<span class='type'>(<tt>String</tt>)</span>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
</li>
|
467
|
+
|
468
|
+
</ul>
|
469
|
+
|
470
|
+
<p class="tag_title">Returns:</p>
|
471
|
+
<ul class="return">
|
472
|
+
|
473
|
+
<li>
|
474
|
+
|
475
|
+
|
476
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
477
|
+
|
478
|
+
|
479
|
+
|
480
|
+
</li>
|
481
|
+
|
482
|
+
</ul>
|
483
|
+
<p class="tag_title">Raises:</p>
|
484
|
+
<ul class="raise">
|
485
|
+
|
486
|
+
<li>
|
487
|
+
|
488
|
+
|
489
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
</li>
|
494
|
+
|
495
|
+
</ul>
|
496
|
+
|
497
|
+
</div><table class="source_code">
|
498
|
+
<tr>
|
499
|
+
<td>
|
500
|
+
<pre class="lines">
|
501
|
+
|
502
|
+
|
503
|
+
79
|
504
|
+
80
|
505
|
+
81
|
506
|
+
82</pre>
|
507
|
+
</td>
|
508
|
+
<td>
|
509
|
+
<pre class="code"><span class="info file"># File 'lib/tango/resource/cache.rb', line 79</span>
|
510
|
+
|
511
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span> <span class='rparen'>)</span>
|
512
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Trying to get resource with unregistered type</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='ivar'>@storage</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span> <span class='rparen'>)</span>
|
513
|
+
<span class='ivar'>@storage</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_cache_key'>cache_key</span><span class='rbracket'>]</span>
|
514
|
+
<span class='kw'>end</span></pre>
|
515
|
+
</td>
|
516
|
+
</tr>
|
517
|
+
</table>
|
518
|
+
</div>
|
519
|
+
|
520
|
+
<div class="method_details ">
|
521
|
+
<h3 class="signature " id="load-instance_method">
|
522
|
+
|
523
|
+
- (<tt>Object</tt>) <strong>load</strong>(type, resource)
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
</h3><div class="docstring">
|
530
|
+
<div class="discussion">
|
531
|
+
|
532
|
+
<p>Get a cached resource or use given block to obtain resource and return it</p>
|
533
|
+
|
534
|
+
|
535
|
+
</div>
|
536
|
+
</div>
|
537
|
+
<div class="tags">
|
538
|
+
<p class="tag_title">Parameters:</p>
|
539
|
+
<ul class="param">
|
540
|
+
|
541
|
+
<li>
|
542
|
+
|
543
|
+
<span class='name'>type</span>
|
544
|
+
|
545
|
+
|
546
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
547
|
+
|
548
|
+
|
549
|
+
|
550
|
+
</li>
|
551
|
+
|
552
|
+
<li>
|
553
|
+
|
554
|
+
<span class='name'>resource</span>
|
555
|
+
|
556
|
+
|
557
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
</li>
|
562
|
+
|
563
|
+
</ul>
|
564
|
+
|
565
|
+
<p class="tag_title">Returns:</p>
|
566
|
+
<ul class="return">
|
567
|
+
|
568
|
+
<li>
|
569
|
+
|
570
|
+
|
571
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
</li>
|
576
|
+
|
577
|
+
</ul>
|
578
|
+
|
579
|
+
</div><table class="source_code">
|
580
|
+
<tr>
|
581
|
+
<td>
|
582
|
+
<pre class="lines">
|
583
|
+
|
584
|
+
|
585
|
+
43
|
586
|
+
44
|
587
|
+
45
|
588
|
+
46
|
589
|
+
47
|
590
|
+
48
|
591
|
+
49
|
592
|
+
50
|
593
|
+
51
|
594
|
+
52
|
595
|
+
53
|
596
|
+
54
|
597
|
+
55
|
598
|
+
56
|
599
|
+
57
|
600
|
+
58
|
601
|
+
59
|
602
|
+
60
|
603
|
+
61
|
604
|
+
62</pre>
|
605
|
+
</td>
|
606
|
+
<td>
|
607
|
+
<pre class="code"><span class="info file"># File 'lib/tango/resource/cache.rb', line 43</span>
|
608
|
+
|
609
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_load'>load</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span> <span class='rparen'>)</span>
|
610
|
+
|
611
|
+
<span class='comment'># Get resource from cache
|
612
|
+
</span> <span class='id identifier rubyid_cached_resource'>cached_resource</span> <span class='op'>=</span> <span class='id identifier rubyid_get'>get</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span> <span class='rparen'>)</span>
|
613
|
+
|
614
|
+
<span class='kw'>unless</span> <span class='id identifier rubyid_cached_resource'>cached_resource</span>
|
615
|
+
|
616
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>No resource callback given</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='id identifier rubyid_block_given?'>block_given?</span>
|
617
|
+
<span class='comment'># If not found, execute yield to receive transformed resource
|
618
|
+
</span> <span class='id identifier rubyid_cached_resource'>cached_resource</span> <span class='op'>=</span> <span class='kw'>yield</span><span class='lparen'>(</span> <span class='id identifier rubyid_resource'>resource</span> <span class='rparen'>)</span>
|
619
|
+
<span class='comment'># Cache new resource
|
620
|
+
</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_cached_resource'>cached_resource</span> <span class='rparen'>)</span>
|
621
|
+
<span class='comment'># Fill buffer with newly cached resource
|
622
|
+
</span> <span class='ivar'>@buffer</span><span class='period'>.</span><span class='id identifier rubyid_fill'>fill</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_cached_resource'>cached_resource</span> <span class='rparen'>)</span>
|
623
|
+
|
624
|
+
<span class='kw'>end</span>
|
625
|
+
|
626
|
+
<span class='id identifier rubyid_cached_resource'>cached_resource</span>
|
627
|
+
|
628
|
+
<span class='kw'>end</span></pre>
|
629
|
+
</td>
|
630
|
+
</tr>
|
631
|
+
</table>
|
632
|
+
</div>
|
633
|
+
|
634
|
+
<div class="method_details ">
|
635
|
+
<h3 class="signature " id="register-instance_method">
|
636
|
+
|
637
|
+
- (<tt><span class='object_link'><a href="" title="Tango::Resource::Cache (class)">Tango::Resource::Cache</a></span></tt>) <strong>register</strong>(type, &release_callback)
|
638
|
+
|
639
|
+
|
640
|
+
|
641
|
+
|
642
|
+
|
643
|
+
</h3><div class="docstring">
|
644
|
+
<div class="discussion">
|
645
|
+
|
646
|
+
<p>Register new type of resource to be cached</p>
|
647
|
+
|
648
|
+
|
649
|
+
</div>
|
650
|
+
</div>
|
651
|
+
<div class="tags">
|
652
|
+
<p class="tag_title">Parameters:</p>
|
653
|
+
<ul class="param">
|
654
|
+
|
655
|
+
<li>
|
656
|
+
|
657
|
+
<span class='name'>type</span>
|
658
|
+
|
659
|
+
|
660
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
661
|
+
|
662
|
+
|
663
|
+
|
664
|
+
</li>
|
665
|
+
|
666
|
+
<li>
|
667
|
+
|
668
|
+
<span class='name'>release_callback</span>
|
669
|
+
|
670
|
+
|
671
|
+
<span class='type'>(<tt>Proc</tt>)</span>
|
672
|
+
|
673
|
+
|
674
|
+
|
675
|
+
</li>
|
676
|
+
|
677
|
+
</ul>
|
678
|
+
|
679
|
+
<p class="tag_title">Returns:</p>
|
680
|
+
<ul class="return">
|
681
|
+
|
682
|
+
<li>
|
683
|
+
|
684
|
+
|
685
|
+
<span class='type'>(<tt><span class='object_link'><a href="" title="Tango::Resource::Cache (class)">Tango::Resource::Cache</a></span></tt>)</span>
|
686
|
+
|
687
|
+
|
688
|
+
|
689
|
+
</li>
|
690
|
+
|
691
|
+
</ul>
|
692
|
+
|
693
|
+
</div><table class="source_code">
|
694
|
+
<tr>
|
695
|
+
<td>
|
696
|
+
<pre class="lines">
|
697
|
+
|
698
|
+
|
699
|
+
27
|
700
|
+
28
|
701
|
+
29
|
702
|
+
30
|
703
|
+
31
|
704
|
+
32
|
705
|
+
33
|
706
|
+
34
|
707
|
+
35
|
708
|
+
36</pre>
|
709
|
+
</td>
|
710
|
+
<td>
|
711
|
+
<pre class="code"><span class="info file"># File 'lib/tango/resource/cache.rb', line 27</span>
|
712
|
+
|
713
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_register'>register</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_release_callback'>release_callback</span> <span class='rparen'>)</span>
|
714
|
+
|
715
|
+
<span class='comment'># Create container for cache of new resource
|
716
|
+
</span> <span class='ivar'>@storage</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
717
|
+
<span class='comment'># Also register new type with buffer
|
718
|
+
</span> <span class='ivar'>@buffer</span><span class='period'>.</span><span class='id identifier rubyid_register'>register</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_release_callback'>release_callback</span> <span class='rparen'>)</span>
|
719
|
+
|
720
|
+
<span class='kw'>self</span>
|
721
|
+
|
722
|
+
<span class='kw'>end</span></pre>
|
723
|
+
</td>
|
724
|
+
</tr>
|
725
|
+
</table>
|
726
|
+
</div>
|
727
|
+
|
728
|
+
<div class="method_details ">
|
729
|
+
<h3 class="signature " id="set-instance_method">
|
730
|
+
|
731
|
+
- (<tt>Object</tt>) <strong>set</strong>(type, resource)
|
732
|
+
|
733
|
+
|
734
|
+
|
735
|
+
|
736
|
+
|
737
|
+
</h3><div class="docstring">
|
738
|
+
<div class="discussion">
|
739
|
+
|
740
|
+
<p>Setter for the cache storage</p>
|
741
|
+
|
742
|
+
|
743
|
+
</div>
|
744
|
+
</div>
|
745
|
+
<div class="tags">
|
746
|
+
<p class="tag_title">Parameters:</p>
|
747
|
+
<ul class="param">
|
748
|
+
|
749
|
+
<li>
|
750
|
+
|
751
|
+
<span class='name'>type</span>
|
752
|
+
|
753
|
+
|
754
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
755
|
+
|
756
|
+
|
757
|
+
|
758
|
+
</li>
|
759
|
+
|
760
|
+
<li>
|
761
|
+
|
762
|
+
<span class='name'>resource</span>
|
763
|
+
|
764
|
+
|
765
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
766
|
+
|
767
|
+
|
768
|
+
|
769
|
+
</li>
|
770
|
+
|
771
|
+
</ul>
|
772
|
+
|
773
|
+
<p class="tag_title">Returns:</p>
|
774
|
+
<ul class="return">
|
775
|
+
|
776
|
+
<li>
|
777
|
+
|
778
|
+
|
779
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
780
|
+
|
781
|
+
|
782
|
+
|
783
|
+
</li>
|
784
|
+
|
785
|
+
</ul>
|
786
|
+
<p class="tag_title">Raises:</p>
|
787
|
+
<ul class="raise">
|
788
|
+
|
789
|
+
<li>
|
790
|
+
|
791
|
+
|
792
|
+
<span class='type'>(<tt>ArgumentError</tt>)</span>
|
793
|
+
|
794
|
+
|
795
|
+
|
796
|
+
</li>
|
797
|
+
|
798
|
+
</ul>
|
799
|
+
|
800
|
+
</div><table class="source_code">
|
801
|
+
<tr>
|
802
|
+
<td>
|
803
|
+
<pre class="lines">
|
804
|
+
|
805
|
+
|
806
|
+
69
|
807
|
+
70
|
808
|
+
71
|
809
|
+
72</pre>
|
810
|
+
</td>
|
811
|
+
<td>
|
812
|
+
<pre class="code"><span class="info file"># File 'lib/tango/resource/cache.rb', line 69</span>
|
813
|
+
|
814
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_set'>set</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span><span class='comma'>,</span> <span class='id identifier rubyid_resource'>resource</span> <span class='rparen'>)</span>
|
815
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>ArgumentError</span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Trying to set resource with unregistered type</span><span class='tstring_end'>"</span></span> <span class='kw'>unless</span> <span class='ivar'>@storage</span><span class='period'>.</span><span class='id identifier rubyid_keys'>keys</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span> <span class='id identifier rubyid_type'>type</span> <span class='rparen'>)</span>
|
816
|
+
<span class='ivar'>@storage</span><span class='lbracket'>[</span><span class='id identifier rubyid_type'>type</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='id identifier rubyid_resource'>resource</span><span class='period'>.</span><span class='id identifier rubyid_cache_key'>cache_key</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_resource'>resource</span>
|
817
|
+
<span class='kw'>end</span></pre>
|
818
|
+
</td>
|
819
|
+
</tr>
|
820
|
+
</table>
|
821
|
+
</div>
|
822
|
+
|
823
|
+
</div>
|
824
|
+
|
825
|
+
</div>
|
826
|
+
|
827
|
+
<div id="footer">
|
828
|
+
Generated on Tue Apr 15 02:47:42 2014 by
|
829
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
830
|
+
0.8.7.4 (ruby-2.0.0).
|
831
|
+
</div>
|
832
|
+
|
833
|
+
</body>
|
834
|
+
</html>
|