rod-rest 0.5.1 → 0.5.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.
@@ -1,3 +1,5 @@
1
+ 0.5.2
2
+ Simplify ProxyCache implementation API
1
3
  0.5.1
2
4
  Fix CollectionProxy#each for empty collection
3
5
  Fix inspection of proxy
@@ -1,5 +1,5 @@
1
1
  module Rod
2
2
  module Rest
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
5
5
  end
@@ -5,25 +5,22 @@ module Rod
5
5
  # Cache used to store proxy objects.
6
6
  class ProxyCache
7
7
  # Initializes empty cache.
8
- def initialize()
9
- @cache_implementation = {}
8
+ def initialize(cache_implementation={})
9
+ @cache_implementation = cache_implementation
10
10
  end
11
11
 
12
12
  # Returns true if the described object is in the cache.
13
13
  def has_key?(description)
14
14
  check_description(description)
15
- @cache_implementation.has_key?(description_signature(description))
15
+ @cache_implementation[description_signature(description)]
16
16
  end
17
17
 
18
18
  # Returns the object stored in the cache. Raises CacheMissed exception if
19
19
  # the result is nil.
20
20
  def [](description)
21
21
  check_description(description)
22
- begin
23
- @cache_implementation.fetch(description_signature(description))
24
- rescue KeyError
25
- raise CacheMissed.new(missing_entry_message(description))
26
- end
22
+ value = @cache_implementation[description_signature(description)]
23
+ raise CacheMissed.new(missing_entry_message(description)) if value.nil?
27
24
  end
28
25
 
29
26
  # Store the +object+ in the cache.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rod-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-28 00:00:00.000000000 Z
12
+ date: 2014-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra