active_remote-cached 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_remote-cached/cache.rb +8 -1
- data/lib/active_remote-cached/version.rb +1 -1
- data/spec/cache_spec.rb +0 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7d2d905a1f2c332e672714d359026c4cdbfbbb8
|
4
|
+
data.tar.gz: c8d4806770678aa49d193ad6fea044817d763b04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0846621184ac0a101620381a333fef148fef114d488d61adb0dada6ba55c8b53f77ba00d38fee49ba63f6ac145a270ab4fbc503c7066f46075687612a7dda39f
|
7
|
+
data.tar.gz: 946302d6ada16ec640746c057916fe10361a004c14b1d13afdce699070a8e34eb154d545683cecfe7314a1154bba3a977901824e21b0f821882a6de01fc7605a
|
@@ -7,7 +7,6 @@ module ActiveRemote::Cached
|
|
7
7
|
def initialize(new_cache_provider)
|
8
8
|
@cache_provider = new_cache_provider
|
9
9
|
validate_provider_method_present(:delete)
|
10
|
-
validate_provider_method_present(:exist?)
|
11
10
|
validate_provider_method_present(:fetch)
|
12
11
|
validate_provider_method_present(:read)
|
13
12
|
validate_provider_method_present(:write)
|
@@ -15,6 +14,14 @@ module ActiveRemote::Cached
|
|
15
14
|
super(@cache_provider)
|
16
15
|
end
|
17
16
|
|
17
|
+
def exist?(key)
|
18
|
+
if self.cache_provider.respond_to?(:exist?)
|
19
|
+
self.cache_provider.exist?(key)
|
20
|
+
else
|
21
|
+
!self.cache_provider.read(key).nil?
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
18
25
|
private
|
19
26
|
|
20
27
|
def validate_provider_method_present(method_name)
|
data/spec/cache_spec.rb
CHANGED
@@ -20,12 +20,6 @@ describe ::ActiveRemote::Cached::Cache do
|
|
20
20
|
error.message.must_match(/respond_to.*delete/i)
|
21
21
|
end
|
22
22
|
|
23
|
-
it "validates #exist? present" do
|
24
|
-
cache = OpenStruct.new(:write => nil, :fetch => nil, :read => nil, :delete => nil)
|
25
|
-
error = lambda { ::ActiveRemote::Cached.cache(cache) }.must_raise(RuntimeError)
|
26
|
-
error.message.must_match(/respond_to.*exist/i)
|
27
|
-
end
|
28
|
-
|
29
23
|
it "validates #fetch present" do
|
30
24
|
cache = OpenStruct.new(:write => nil, :delete => nil, :read => nil, :exist? => nil)
|
31
25
|
error = lambda { ::ActiveRemote::Cached.cache(cache) }.must_raise(RuntimeError)
|