hashcache 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. data/lib/hashcache.rb +8 -4
  2. metadata +2 -2
data/lib/hashcache.rb CHANGED
@@ -13,10 +13,7 @@ class HashCache
13
13
 
14
14
  def read(item)
15
15
  if @h.include? item then
16
- val = @h[item]
17
- @h.delete(item)
18
- @h[item] = val
19
- val
16
+ self.refresh item
20
17
  else
21
18
  val = yield
22
19
  @h[item] = val
@@ -24,6 +21,13 @@ class HashCache
24
21
  val
25
22
  end
26
23
  end
24
+
25
+ def refresh(item)
26
+ val = @h[item]
27
+ @h.delete item
28
+ @h[item] = val
29
+ val
30
+ end
27
31
 
28
32
  def reset
29
33
  @h = {}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashcache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-07-16 00:00:00 +01:00
12
+ date: 2010-07-19 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15