cache-object 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ccaaecfb055eeb74feef3c2cd4447b19789f128a
|
4
|
+
data.tar.gz: 2ab0deb7a2a7d6f5ddd529d2fcd7a5d6e6f1edcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac61615c7da8577d9c9be7a4eb8677caea2484b641cd327a700c27c3cebe2849662c946eb4e6f93802e88077387612c7a08940657e0398a22f2767d830a8fc48
|
7
|
+
data.tar.gz: 7aa792ad602a7b75f53545d98b3bb1704b0910830caf9908de5217e513c011d9adc3183b84b727d74312eb076d2760d13bb27da5889a2484667d1a464d988010
|
@@ -37,10 +37,12 @@ module Cache
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def write_cache!
|
40
|
+
return unless self.send(self.class.primary_key)
|
40
41
|
Cache::Object.adapter.write(_cache_object_decorator)
|
41
42
|
end
|
42
43
|
|
43
44
|
def expire_cache!
|
45
|
+
return unless self.send(self.class.primary_key)
|
44
46
|
Cache::Object.adapter.delete(_cache_object_decorator)
|
45
47
|
end
|
46
48
|
|
data/lib/cache/object/version.rb
CHANGED
@@ -25,6 +25,14 @@ RSpec.describe Cache::Object::ActiveRecord do
|
|
25
25
|
class Model < FakeActiveRecord
|
26
26
|
include Cache::Object::ActiveRecord
|
27
27
|
|
28
|
+
def self.primary_key
|
29
|
+
:id
|
30
|
+
end
|
31
|
+
|
32
|
+
def id
|
33
|
+
Random.rand * 100
|
34
|
+
end
|
35
|
+
|
28
36
|
object_cache_on :name, :age
|
29
37
|
end
|
30
38
|
|
@@ -99,8 +107,7 @@ RSpec.describe Cache::Object::ActiveRecord do
|
|
99
107
|
describe ".find_by_id" do
|
100
108
|
describe "caching interactions" do
|
101
109
|
it "yields to super with cache" do
|
102
|
-
expect(super_clazz).to receive(:
|
103
|
-
expect(super_clazz).to receive(:where).with("primary_key" => 12).once { double(first: true) }
|
110
|
+
expect(super_clazz).to receive(:where).with(:id => 12).once { double(first: true) }
|
104
111
|
clazz.find_by_id(12)
|
105
112
|
end
|
106
113
|
end
|
@@ -101,5 +101,12 @@ RSpec.describe "Caching" do
|
|
101
101
|
end
|
102
102
|
end
|
103
103
|
|
104
|
+
describe "when object is not persisted" do
|
105
|
+
it "does not call the adapter" do
|
106
|
+
expect(Cache::Object.adapter).to receive(:write).never
|
107
|
+
User.new(name: "blah").write_cache!
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
104
111
|
|
105
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cache-object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Camuto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|