elephas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. data/.gitignore +5 -0
  2. data/.travis.yml +8 -0
  3. data/.yardopts +1 -0
  4. data/Gemfile +9 -0
  5. data/README.md +28 -0
  6. data/Rakefile +18 -0
  7. data/doc/Elephas/Cache.html +815 -0
  8. data/doc/Elephas/Entry.html +1085 -0
  9. data/doc/Elephas/Exceptions.html +115 -0
  10. data/doc/Elephas/Providers/Base.html +701 -0
  11. data/doc/Elephas/Providers/Hash.html +775 -0
  12. data/doc/Elephas/Providers/RubyOnRails.html +609 -0
  13. data/doc/Elephas/Providers.html +129 -0
  14. data/doc/Elephas/Version.html +189 -0
  15. data/doc/Elephas.html +130 -0
  16. data/doc/_index.html +207 -0
  17. data/doc/class_list.html +53 -0
  18. data/doc/css/common.css +1 -0
  19. data/doc/css/full_list.css +57 -0
  20. data/doc/css/style.css +328 -0
  21. data/doc/file.README.html +103 -0
  22. data/doc/file_list.html +55 -0
  23. data/doc/frames.html +28 -0
  24. data/doc/index.html +103 -0
  25. data/doc/js/app.js +214 -0
  26. data/doc/js/full_list.js +173 -0
  27. data/doc/js/jquery.js +4 -0
  28. data/doc/method_list.html +300 -0
  29. data/doc/top-level-namespace.html +112 -0
  30. data/elephas.gemspec +34 -0
  31. data/lib/elephas/cache.rb +89 -0
  32. data/lib/elephas/entry.rb +86 -0
  33. data/lib/elephas/provider.rb +57 -0
  34. data/lib/elephas/providers/hash.rb +65 -0
  35. data/lib/elephas/providers/ruby_on_rails.rb +57 -0
  36. data/lib/elephas/version.rb +25 -0
  37. data/lib/elephas.rb +20 -0
  38. data/spec/coverage_helper.rb +19 -0
  39. data/spec/elephas/cache_spec.rb +41 -0
  40. data/spec/elephas/entry_spec.rb +11 -0
  41. data/spec/elephas/provider_spec.rb +46 -0
  42. data/spec/elephas/providers/hash_spec.rb +80 -0
  43. data/spec/elephas/providers/ruby_on_rails_spec.rb +86 -0
  44. data/spec/spec_helper.rb +16 -0
  45. metadata +231 -0
@@ -0,0 +1,1085 @@
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: Elephas::Entry
8
+
9
+ &mdash; Documentation by YARD 0.8.2.1
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="../css/common.css" type="text/css" media="screen" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ hasFrames = window.top.frames.main ? true : false;
19
+ relpath = '../';
20
+ framesUrl = "../frames.html#!" + escape(window.location.href);
21
+ </script>
22
+
23
+
24
+ <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
25
+
26
+ <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
27
+
28
+
29
+ </head>
30
+ <body>
31
+ <div id="header">
32
+ <div id="menu">
33
+
34
+ <a href="../_index.html">Index (E)</a> &raquo;
35
+ <span class='title'><span class='object_link'><a href="../Elephas.html" title="Elephas (module)">Elephas</a></span></span>
36
+ &raquo;
37
+ <span class="title">Entry</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: Elephas::Entry
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">Elephas::Entry</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/elephas/entry.rb</dd>
98
+
99
+ </dl>
100
+ <div class="clear"></div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+ <p>This represents a cache entry.</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="#hash-instance_method" title="#hash (instance method)">- (Object) <strong>hash</strong> </a>
123
+
124
+
125
+
126
+ </span>
127
+
128
+
129
+
130
+
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+ <span class="summary_desc"><div class='inline'><p>The hashed (unique) key for this entry.</p>
140
+ </div></span>
141
+
142
+ </li>
143
+
144
+
145
+ <li class="public ">
146
+ <span class="summary_signature">
147
+
148
+ <a href="#key-instance_method" title="#key (instance method)">- (Object) <strong>key</strong> </a>
149
+
150
+
151
+
152
+ </span>
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+ <span class="summary_desc"><div class='inline'><p>The key for this entry.</p>
166
+ </div></span>
167
+
168
+ </li>
169
+
170
+
171
+ <li class="public ">
172
+ <span class="summary_signature">
173
+
174
+ <a href="#ttl-instance_method" title="#ttl (instance method)">- (Object) <strong>ttl</strong> </a>
175
+
176
+
177
+
178
+ </span>
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+ <span class="summary_desc"><div class='inline'><p>The expected TTL of the entry, in milliseconds.</p>
192
+ </div></span>
193
+
194
+ </li>
195
+
196
+
197
+ <li class="public ">
198
+ <span class="summary_signature">
199
+
200
+ <a href="#updated_at-instance_method" title="#updated_at (instance method)">- (Object) <strong>updated_at</strong> </a>
201
+
202
+
203
+
204
+ </span>
205
+
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+ <span class="summary_desc"><div class='inline'><p>The last update date of the entry, in UNIX timestamp (with milliseconds).</p>
218
+ </div></span>
219
+
220
+ </li>
221
+
222
+
223
+ <li class="public ">
224
+ <span class="summary_signature">
225
+
226
+ <a href="#value-instance_method" title="#value (instance method)">- (Object) <strong>value</strong> </a>
227
+
228
+
229
+
230
+ </span>
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+ <span class="summary_desc"><div class='inline'><p>The value contained in this entry.</p>
244
+ </div></span>
245
+
246
+ </li>
247
+
248
+
249
+ </ul>
250
+
251
+
252
+
253
+
254
+
255
+ <h2>
256
+ Class Method Summary
257
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
258
+ </h2>
259
+
260
+ <ul class="summary">
261
+
262
+ <li class="public ">
263
+ <span class="summary_signature">
264
+
265
+ <a href="#ensure-class_method" title="ensure (class method)">+ (Entry) <strong>ensure</strong>(value, key, options = {}) </a>
266
+
267
+
268
+
269
+ </span>
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+ <span class="summary_desc"><div class='inline'><p>Ensure that the value is an Entry.</p>
280
+ </div></span>
281
+
282
+ </li>
283
+
284
+
285
+ <li class="public ">
286
+ <span class="summary_signature">
287
+
288
+ <a href="#hashify_key-class_method" title="hashify_key (class method)">+ (String) <strong>hashify_key</strong>(key) </a>
289
+
290
+
291
+
292
+ </span>
293
+
294
+
295
+
296
+
297
+
298
+
299
+
300
+
301
+
302
+ <span class="summary_desc"><div class='inline'><p>Returns a unique hash for the key.</p>
303
+ </div></span>
304
+
305
+ </li>
306
+
307
+
308
+ </ul>
309
+
310
+ <h2>
311
+ Instance Method Summary
312
+ <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
313
+ </h2>
314
+
315
+ <ul class="summary">
316
+
317
+ <li class="public ">
318
+ <span class="summary_signature">
319
+
320
+ <a href="#initialize-instance_method" title="#initialize (instance method)">- (Entry) <strong>initialize</strong>(key, value, hash = nil, ttl = 3600) </a>
321
+
322
+
323
+
324
+ </span>
325
+
326
+
327
+ <span class="note title constructor">constructor</span>
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+
336
+ <span class="summary_desc"><div class='inline'><p>Creates a new entry.</p>
337
+ </div></span>
338
+
339
+ </li>
340
+
341
+
342
+ <li class="public ">
343
+ <span class="summary_signature">
344
+
345
+ <a href="#refresh-instance_method" title="#refresh (instance method)">- (Object) <strong>refresh</strong>(save = false) </a>
346
+
347
+
348
+
349
+ </span>
350
+
351
+
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+ <span class="summary_desc"><div class='inline'><p>Refreshes the entry.</p>
360
+ </div></span>
361
+
362
+ </li>
363
+
364
+
365
+ <li class="public ">
366
+ <span class="summary_signature">
367
+
368
+ <a href="#valid%3F-instance_method" title="#valid? (instance method)">- (Boolean) <strong>valid?</strong>(provider = nil) </a>
369
+
370
+
371
+
372
+ </span>
373
+
374
+
375
+
376
+
377
+
378
+
379
+
380
+
381
+
382
+ <span class="summary_desc"><div class='inline'><p>Checks if the entry is still valid.</p>
383
+ </div></span>
384
+
385
+ </li>
386
+
387
+
388
+ </ul>
389
+
390
+
391
+ <div id="constructor_details" class="method_details_list">
392
+ <h2>Constructor Details</h2>
393
+
394
+ <div class="method_details first">
395
+ <h3 class="signature first" id="initialize-instance_method">
396
+
397
+ - (<tt><span class='object_link'><a href="" title="Elephas::Entry (class)">Entry</a></span></tt>) <strong>initialize</strong>(key, value, hash = nil, ttl = 3600)
398
+
399
+
400
+
401
+
402
+
403
+ </h3><div class="docstring">
404
+ <div class="discussion">
405
+ <p>Creates a new entry.</p>
406
+
407
+
408
+ </div>
409
+ </div>
410
+ <div class="tags">
411
+ <p class="tag_title">Parameters:</p>
412
+ <ul class="param">
413
+
414
+ <li>
415
+
416
+ <span class='name'>key</span>
417
+
418
+
419
+ <span class='type'>(<tt>String</tt>)</span>
420
+
421
+
422
+
423
+ &mdash;
424
+ <div class='inline'><p>The key for this entry.</p>
425
+ </div>
426
+
427
+ </li>
428
+
429
+ <li>
430
+
431
+ <span class='name'>value</span>
432
+
433
+
434
+ <span class='type'>(<tt>Object</tt>)</span>
435
+
436
+
437
+
438
+ &mdash;
439
+ <div class='inline'><p>The value contained in this entry.</p>
440
+ </div>
441
+
442
+ </li>
443
+
444
+ <li>
445
+
446
+ <span class='name'>hash</span>
447
+
448
+
449
+ <span class='type'>(<tt>String</tt>)</span>
450
+
451
+
452
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
453
+
454
+
455
+ &mdash;
456
+ <div class='inline'><p>The hash for this entry. Should be unique. It is automatically created if not provided.</p>
457
+ </div>
458
+
459
+ </li>
460
+
461
+ <li>
462
+
463
+ <span class='name'>ttl</span>
464
+
465
+
466
+ <span class='type'>(<tt>Integer</tt>)</span>
467
+
468
+
469
+ <em class="default">(defaults to: <tt>3600</tt>)</em>
470
+
471
+
472
+ &mdash;
473
+ <div class='inline'><p>The time to live (TTL) for this entry. If set to 0 then the entry is not cached.</p>
474
+ </div>
475
+
476
+ </li>
477
+
478
+ </ul>
479
+
480
+
481
+ </div><table class="source_code">
482
+ <tr>
483
+ <td>
484
+ <pre class="lines">
485
+
486
+
487
+ 31
488
+ 32
489
+ 33
490
+ 34
491
+ 35
492
+ 36
493
+ 37
494
+ 38</pre>
495
+ </td>
496
+ <td>
497
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 31</span>
498
+
499
+ <span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>=</span> <span class='int'>3600</span><span class='rparen'>)</span>
500
+ <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_hashify_key'>hashify_key</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='id identifier rubyid_hash'>hash</span><span class='period'>.</span><span class='id identifier rubyid_blank?'>blank?</span>
501
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span> <span class='op'>=</span> <span class='id identifier rubyid_key'>key</span>
502
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='id identifier rubyid_hash'>hash</span>
503
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
504
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>=</span> <span class='id identifier rubyid_ttl'>ttl</span>
505
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_refresh'>refresh</span>
506
+ <span class='kw'>end</span></pre>
507
+ </td>
508
+ </tr>
509
+ </table>
510
+ </div>
511
+
512
+ </div>
513
+
514
+ <div id="instance_attr_details" class="attr_details">
515
+ <h2>Instance Attribute Details</h2>
516
+
517
+
518
+ <span id="hash=-instance_method"></span>
519
+ <div class="method_details first">
520
+ <h3 class="signature first" id="hash-instance_method">
521
+
522
+ - (<tt>Object</tt>) <strong>hash</strong>
523
+
524
+
525
+
526
+
527
+
528
+ </h3><div class="docstring">
529
+ <div class="discussion">
530
+ <p>The hashed (unique) key for this entry.</p>
531
+
532
+
533
+ </div>
534
+ </div>
535
+ <div class="tags">
536
+
537
+
538
+ </div><table class="source_code">
539
+ <tr>
540
+ <td>
541
+ <pre class="lines">
542
+
543
+
544
+ 14
545
+ 15
546
+ 16</pre>
547
+ </td>
548
+ <td>
549
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 14</span>
550
+
551
+ <span class='kw'>def</span> <span class='id identifier rubyid_hash'>hash</span>
552
+ <span class='ivar'>@hash</span>
553
+ <span class='kw'>end</span></pre>
554
+ </td>
555
+ </tr>
556
+ </table>
557
+ </div>
558
+
559
+
560
+ <span id="key=-instance_method"></span>
561
+ <div class="method_details ">
562
+ <h3 class="signature " id="key-instance_method">
563
+
564
+ - (<tt>Object</tt>) <strong>key</strong>
565
+
566
+
567
+
568
+
569
+
570
+ </h3><div class="docstring">
571
+ <div class="discussion">
572
+ <p>The key for this entry.</p>
573
+
574
+
575
+ </div>
576
+ </div>
577
+ <div class="tags">
578
+
579
+
580
+ </div><table class="source_code">
581
+ <tr>
582
+ <td>
583
+ <pre class="lines">
584
+
585
+
586
+ 11
587
+ 12
588
+ 13</pre>
589
+ </td>
590
+ <td>
591
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 11</span>
592
+
593
+ <span class='kw'>def</span> <span class='id identifier rubyid_key'>key</span>
594
+ <span class='ivar'>@key</span>
595
+ <span class='kw'>end</span></pre>
596
+ </td>
597
+ </tr>
598
+ </table>
599
+ </div>
600
+
601
+
602
+ <span id="ttl=-instance_method"></span>
603
+ <div class="method_details ">
604
+ <h3 class="signature " id="ttl-instance_method">
605
+
606
+ - (<tt>Object</tt>) <strong>ttl</strong>
607
+
608
+
609
+
610
+
611
+
612
+ </h3><div class="docstring">
613
+ <div class="discussion">
614
+ <p>The expected TTL of the entry, in milliseconds.</p>
615
+
616
+
617
+ </div>
618
+ </div>
619
+ <div class="tags">
620
+
621
+
622
+ </div><table class="source_code">
623
+ <tr>
624
+ <td>
625
+ <pre class="lines">
626
+
627
+
628
+ 20
629
+ 21
630
+ 22</pre>
631
+ </td>
632
+ <td>
633
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 20</span>
634
+
635
+ <span class='kw'>def</span> <span class='id identifier rubyid_ttl'>ttl</span>
636
+ <span class='ivar'>@ttl</span>
637
+ <span class='kw'>end</span></pre>
638
+ </td>
639
+ </tr>
640
+ </table>
641
+ </div>
642
+
643
+
644
+ <span id="updated_at=-instance_method"></span>
645
+ <div class="method_details ">
646
+ <h3 class="signature " id="updated_at-instance_method">
647
+
648
+ - (<tt>Object</tt>) <strong>updated_at</strong>
649
+
650
+
651
+
652
+
653
+
654
+ </h3><div class="docstring">
655
+ <div class="discussion">
656
+ <p>The last update date of the entry, in UNIX timestamp (with milliseconds).</p>
657
+
658
+
659
+ </div>
660
+ </div>
661
+ <div class="tags">
662
+
663
+
664
+ </div><table class="source_code">
665
+ <tr>
666
+ <td>
667
+ <pre class="lines">
668
+
669
+
670
+ 23
671
+ 24
672
+ 25</pre>
673
+ </td>
674
+ <td>
675
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 23</span>
676
+
677
+ <span class='kw'>def</span> <span class='id identifier rubyid_updated_at'>updated_at</span>
678
+ <span class='ivar'>@updated_at</span>
679
+ <span class='kw'>end</span></pre>
680
+ </td>
681
+ </tr>
682
+ </table>
683
+ </div>
684
+
685
+
686
+ <span id="value=-instance_method"></span>
687
+ <div class="method_details ">
688
+ <h3 class="signature " id="value-instance_method">
689
+
690
+ - (<tt>Object</tt>) <strong>value</strong>
691
+
692
+
693
+
694
+
695
+
696
+ </h3><div class="docstring">
697
+ <div class="discussion">
698
+ <p>The value contained in this entry.</p>
699
+
700
+
701
+ </div>
702
+ </div>
703
+ <div class="tags">
704
+
705
+
706
+ </div><table class="source_code">
707
+ <tr>
708
+ <td>
709
+ <pre class="lines">
710
+
711
+
712
+ 17
713
+ 18
714
+ 19</pre>
715
+ </td>
716
+ <td>
717
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 17</span>
718
+
719
+ <span class='kw'>def</span> <span class='id identifier rubyid_value'>value</span>
720
+ <span class='ivar'>@value</span>
721
+ <span class='kw'>end</span></pre>
722
+ </td>
723
+ </tr>
724
+ </table>
725
+ </div>
726
+
727
+ </div>
728
+
729
+
730
+ <div id="class_method_details" class="method_details_list">
731
+ <h2>Class Method Details</h2>
732
+
733
+
734
+ <div class="method_details first">
735
+ <h3 class="signature first" id="ensure-class_method">
736
+
737
+ + (<tt><span class='object_link'><a href="" title="Elephas::Entry (class)">Entry</a></span></tt>) <strong>ensure</strong>(value, key, options = {})
738
+
739
+
740
+
741
+
742
+
743
+ </h3><div class="docstring">
744
+ <div class="discussion">
745
+ <p>Ensure that the value is an Entry.</p>
746
+
747
+
748
+ </div>
749
+ </div>
750
+ <div class="tags">
751
+ <p class="tag_title">Parameters:</p>
752
+ <ul class="param">
753
+
754
+ <li>
755
+
756
+ <span class='name'>value</span>
757
+
758
+
759
+ <span class='type'>(<tt>Object</tt>)</span>
760
+
761
+
762
+
763
+ &mdash;
764
+ <div class='inline'><p>The object to check.</p>
765
+ </div>
766
+
767
+ </li>
768
+
769
+ <li>
770
+
771
+ <span class='name'>key</span>
772
+
773
+
774
+ <span class='type'>(<tt>Object</tt>)</span>
775
+
776
+
777
+
778
+ &mdash;
779
+ <div class='inline'><p>The key associated to this object.</p>
780
+ </div>
781
+
782
+ </li>
783
+
784
+ </ul>
785
+
786
+ <p class="tag_title">Returns:</p>
787
+ <ul class="return">
788
+
789
+ <li>
790
+
791
+
792
+ <span class='type'>(<tt><span class='object_link'><a href="" title="Elephas::Entry (class)">Entry</a></span></tt>)</span>
793
+
794
+
795
+
796
+ &mdash;
797
+ <div class='inline'><p>The wrapped object.</p>
798
+ </div>
799
+
800
+ </li>
801
+
802
+ </ul>
803
+
804
+ </div><table class="source_code">
805
+ <tr>
806
+ <td>
807
+ <pre class="lines">
808
+
809
+
810
+ 71
811
+ 72
812
+ 73
813
+ 74
814
+ 75
815
+ 76
816
+ 77
817
+ 78
818
+ 79
819
+ 80
820
+ 81
821
+ 82
822
+ 83
823
+ 84</pre>
824
+ </td>
825
+ <td>
826
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 71</span>
827
+
828
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='kw'>ensure</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='comma'>,</span> <span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span><span class='rparen'>)</span>
829
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span>
830
+
831
+ <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_rv'>rv</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='rparen'>)</span> <span class='kw'>then</span>
832
+ <span class='id identifier rubyid_options'>options</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span> <span class='kw'>if</span> <span class='op'>!</span><span class='id identifier rubyid_options'>options</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Hash</span><span class='rparen'>)</span>
833
+
834
+ <span class='id identifier rubyid_ttl'>ttl</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:ttl</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_to_integer'>to_integer</span><span class='comma'>,</span> <span class='int'>0</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_max'>max</span>
835
+ <span class='id identifier rubyid_hash'>hash</span> <span class='op'>=</span> <span class='id identifier rubyid_options'>options</span><span class='lbracket'>[</span><span class='symbol'>:hash</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_hashify_key'>hashify_key</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
836
+
837
+ <span class='id identifier rubyid_rv'>rv</span> <span class='op'>=</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Entry</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='id identifier rubyid_rv'>rv</span><span class='comma'>,</span> <span class='id identifier rubyid_hash'>hash</span><span class='comma'>,</span> <span class='id identifier rubyid_ttl'>ttl</span><span class='rparen'>)</span>
838
+ <span class='kw'>end</span>
839
+
840
+ <span class='id identifier rubyid_rv'>rv</span>
841
+ <span class='kw'>end</span></pre>
842
+ </td>
843
+ </tr>
844
+ </table>
845
+ </div>
846
+
847
+ <div class="method_details ">
848
+ <h3 class="signature " id="hashify_key-class_method">
849
+
850
+ + (<tt>String</tt>) <strong>hashify_key</strong>(key)
851
+
852
+
853
+
854
+
855
+
856
+ </h3><div class="docstring">
857
+ <div class="discussion">
858
+ <p>Returns a unique hash for the key.</p>
859
+
860
+
861
+ </div>
862
+ </div>
863
+ <div class="tags">
864
+ <p class="tag_title">Parameters:</p>
865
+ <ul class="param">
866
+
867
+ <li>
868
+
869
+ <span class='name'>key</span>
870
+
871
+
872
+ <span class='type'>(<tt>String</tt>)</span>
873
+
874
+
875
+
876
+ &mdash;
877
+ <div class='inline'><p>The key to hashify.</p>
878
+ </div>
879
+
880
+ </li>
881
+
882
+ </ul>
883
+
884
+ <p class="tag_title">Returns:</p>
885
+ <ul class="return">
886
+
887
+ <li>
888
+
889
+
890
+ <span class='type'>(<tt>String</tt>)</span>
891
+
892
+
893
+
894
+ &mdash;
895
+ <div class='inline'><p>An unique hash for the key.</p>
896
+ </div>
897
+
898
+ </li>
899
+
900
+ </ul>
901
+
902
+ </div><table class="source_code">
903
+ <tr>
904
+ <td>
905
+ <pre class="lines">
906
+
907
+
908
+ 62
909
+ 63
910
+ 64</pre>
911
+ </td>
912
+ <td>
913
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 62</span>
914
+
915
+ <span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_hashify_key'>hashify_key</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
916
+ <span class='const'>Digest</span><span class='op'>::</span><span class='const'>SHA2</span><span class='period'>.</span><span class='id identifier rubyid_hexdigest'>hexdigest</span><span class='lparen'>(</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_ensure_string'>ensure_string</span><span class='rparen'>)</span>
917
+ <span class='kw'>end</span></pre>
918
+ </td>
919
+ </tr>
920
+ </table>
921
+ </div>
922
+
923
+ </div>
924
+
925
+ <div id="instance_method_details" class="method_details_list">
926
+ <h2>Instance Method Details</h2>
927
+
928
+
929
+ <div class="method_details first">
930
+ <h3 class="signature first" id="refresh-instance_method">
931
+
932
+ - (<tt>Object</tt>) <strong>refresh</strong>(save = false)
933
+
934
+
935
+
936
+
937
+
938
+ </h3><div class="docstring">
939
+ <div class="discussion">
940
+ <p>Refreshes the entry.</p>
941
+
942
+
943
+ </div>
944
+ </div>
945
+ <div class="tags">
946
+ <p class="tag_title">Parameters:</p>
947
+ <ul class="param">
948
+
949
+ <li>
950
+
951
+ <span class='name'>save</span>
952
+
953
+
954
+ <span class='type'>(<tt>Boolean</tt>)</span>
955
+
956
+
957
+ <em class="default">(defaults to: <tt>false</tt>)</em>
958
+
959
+
960
+ &mdash;
961
+ <div class='inline'><p>If to save the refresh value in the cache.</p>
962
+ </div>
963
+
964
+ </li>
965
+
966
+ </ul>
967
+
968
+
969
+ </div><table class="source_code">
970
+ <tr>
971
+ <td>
972
+ <pre class="lines">
973
+
974
+
975
+ 43
976
+ 44
977
+ 45
978
+ 46
979
+ 47</pre>
980
+ </td>
981
+ <td>
982
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 43</span>
983
+
984
+ <span class='kw'>def</span> <span class='id identifier rubyid_refresh'>refresh</span><span class='lparen'>(</span><span class='id identifier rubyid_save'>save</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
985
+ <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'>=</span> <span class='const'>Time</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span><span class='period'>.</span><span class='id identifier rubyid_to_f'>to_f</span>
986
+
987
+ <span class='comment'># TODO: Set this value in the cache
988
+ </span><span class='kw'>end</span></pre>
989
+ </td>
990
+ </tr>
991
+ </table>
992
+ </div>
993
+
994
+ <div class="method_details ">
995
+ <h3 class="signature " id="valid?-instance_method">
996
+
997
+ - (<tt>Boolean</tt>) <strong>valid?</strong>(provider = nil)
998
+
999
+
1000
+
1001
+
1002
+
1003
+ </h3><div class="docstring">
1004
+ <div class="discussion">
1005
+ <p>Checks if the entry is still valid.</p>
1006
+
1007
+
1008
+ </div>
1009
+ </div>
1010
+ <div class="tags">
1011
+ <p class="tag_title">Parameters:</p>
1012
+ <ul class="param">
1013
+
1014
+ <li>
1015
+
1016
+ <span class='name'>provider</span>
1017
+
1018
+
1019
+ <span class='type'>(<tt>Provider::Base</tt>)</span>
1020
+
1021
+
1022
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
1023
+
1024
+
1025
+ &mdash;
1026
+ <div class='inline'><p>The provider to use for the check.</p>
1027
+ </div>
1028
+
1029
+ </li>
1030
+
1031
+ </ul>
1032
+
1033
+ <p class="tag_title">Returns:</p>
1034
+ <ul class="return">
1035
+
1036
+ <li>
1037
+
1038
+
1039
+ <span class='type'>(<tt>Boolean</tt>)</span>
1040
+
1041
+
1042
+
1043
+ &mdash;
1044
+ <div class='inline'><p><code>true</code> if the entry is still valid, <code>false</code> otherwise.</p>
1045
+ </div>
1046
+
1047
+ </li>
1048
+
1049
+ </ul>
1050
+
1051
+ </div><table class="source_code">
1052
+ <tr>
1053
+ <td>
1054
+ <pre class="lines">
1055
+
1056
+
1057
+ 53
1058
+ 54
1059
+ 55
1060
+ 56</pre>
1061
+ </td>
1062
+ <td>
1063
+ <pre class="code"><span class="info file"># File 'lib/elephas/entry.rb', line 53</span>
1064
+
1065
+ <span class='kw'>def</span> <span class='id identifier rubyid_valid?'>valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_provider'>provider</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='rparen'>)</span>
1066
+ <span class='id identifier rubyid_provider'>provider</span> <span class='op'>||=</span> <span class='op'>::</span><span class='const'>Elephas</span><span class='op'>::</span><span class='const'>Cache</span><span class='period'>.</span><span class='id identifier rubyid_provider'>provider</span>
1067
+ <span class='id identifier rubyid_provider'>provider</span><span class='period'>.</span><span class='id identifier rubyid_now'>now</span> <span class='op'>-</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_updated_at'>updated_at</span> <span class='op'>&lt;</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_ttl'>ttl</span>
1068
+ <span class='kw'>end</span></pre>
1069
+ </td>
1070
+ </tr>
1071
+ </table>
1072
+ </div>
1073
+
1074
+ </div>
1075
+
1076
+ </div>
1077
+
1078
+ <div id="footer">
1079
+ Generated on Sat Jul 28 14:29:52 2012 by
1080
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1081
+ 0.8.2.1 (ruby-1.9.2).
1082
+ </div>
1083
+
1084
+ </body>
1085
+ </html>