simple_cacheable 1.5.0 → 1.5.1
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.
- checksums.yaml +4 -4
- data/ChangeLog +3 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/gemfiles/3.2.gemfile.lock +1 -1
- data/gemfiles/4.0.gemfile.lock +1 -1
- data/lib/cacheable/model_fetch.rb +4 -2
- data/lib/cacheable/version.rb +1 -1
- data/spec/cacheable/model_fetch_spec.rb +9 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c71b997e052ffde01ff5884758b05dee7235e6b
|
4
|
+
data.tar.gz: 6029c248ca8f61a8e778dde941cb9fe19ff05f35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 206491b0464e80ab19364898fb675497a1ab38d4f25ee722e786f2a2bc746fa77bf9377335c2b76c293f5f2ad8e772d2a8a0fe7a21096dcb704e68248392e7fe
|
7
|
+
data.tar.gz: 24acdbddc8cba8543780d192bc942398d29c95fe241ed853bb2e60cd143a72578a3957196ce5e760e743009f827b1a9325b131d9a8bbde0377c61f3919919494
|
data/ChangeLog
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
Simple Cacheable [](https://travis-ci.org/flyerhzm/simple_cacheable)
|
2
2
|
=========
|
3
3
|
|
4
|
-
|
4
|
+
Simple Cacheable is a simple cache implementation based on activerecord, it is
|
5
5
|
extracted from [rails-bestpractices.com][1].
|
6
6
|
|
7
|
-
it supports activerecord >= 3.0.0, tested on
|
7
|
+
it supports activerecord >= 3.0.0, tested on 2.0.0 and works with jruby.
|
8
8
|
|
9
9
|
Introduction
|
10
10
|
------------
|
data/gemfiles/3.2.gemfile.lock
CHANGED
data/gemfiles/4.0.gemfile.lock
CHANGED
@@ -30,7 +30,7 @@ module Cacheable
|
|
30
30
|
value = Rails.cache.read(key, options)
|
31
31
|
return nil if value.nil?
|
32
32
|
|
33
|
-
if !
|
33
|
+
if !value.is_a?(Hash) && value.respond_to?(:to_a)
|
34
34
|
value.to_a.map { |obj| record_from_coder(obj) }
|
35
35
|
else
|
36
36
|
record_from_coder(value)
|
@@ -48,7 +48,9 @@ module Cacheable
|
|
48
48
|
|
49
49
|
def record_from_coder(coder)
|
50
50
|
return coder unless coder?(coder)
|
51
|
-
|
51
|
+
klass = coder[:class]
|
52
|
+
return coder unless klass.is_a?(Class)
|
53
|
+
record = klass.allocate
|
52
54
|
record.init_with(coder)
|
53
55
|
end
|
54
56
|
|
data/lib/cacheable/version.rb
CHANGED
@@ -77,10 +77,17 @@ describe Cacheable do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "returning a hash with class key" do
|
80
|
+
it "handles a hash with a class key at fetch level" do
|
81
|
+
key = "cacheable_hash"
|
82
|
+
hash_value = {:superman => "Clark Kent", :batman => "Bruce Wayne"}
|
83
|
+
Cacheable.send(:write, key, hash_value)
|
84
|
+
Cacheable.send(:read, key).should == hash_value
|
85
|
+
end
|
86
|
+
|
80
87
|
it "handles a hash with a class key" do
|
81
|
-
hash_value =
|
82
|
-
@user.cached_hash_with_class_key.should == hash_value
|
88
|
+
hash_value = @user.hash_with_class_key
|
83
89
|
@user.cached_hash_with_class_key.should == hash_value
|
90
|
+
User.first.cached_hash_with_class_key.should == hash_value
|
84
91
|
end
|
85
92
|
end
|
86
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_cacheable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|