simple_cacheable 1.5.0 → 1.5.1

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: 87dfaba75352a1ad0723253e70dc284bb7e5be24
4
- data.tar.gz: f7cf5fcd01962777884b277f0c5cc882d1c91155
3
+ metadata.gz: 9c71b997e052ffde01ff5884758b05dee7235e6b
4
+ data.tar.gz: 6029c248ca8f61a8e778dde941cb9fe19ff05f35
5
5
  SHA512:
6
- metadata.gz: cce398f40d4d4ac785b5ec0b497ac94fe2c9b6994793cb8ca2d3f7897df5f2ffce9bcad2e9476966a56644cfc1755a693b19940c120f9b2b3329111e2b751e81
7
- data.tar.gz: 74922005637353c9f67739702c2cd1f16ac8b8b23fc4890d43d57a0a9e5a5908b49c2dac61049efbb37e06b20eb6b174e8860a0e78267db581b0e966d12129ec
6
+ metadata.gz: 206491b0464e80ab19364898fb675497a1ab38d4f25ee722e786f2a2bc746fa77bf9377335c2b76c293f5f2ad8e772d2a8a0fe7a21096dcb704e68248392e7fe
7
+ data.tar.gz: 24acdbddc8cba8543780d192bc942398d29c95fe241ed853bb2e60cd143a72578a3957196ce5e760e743009f827b1a9325b131d9a8bbde0377c61f3919919494
data/ChangeLog CHANGED
@@ -1,3 +1,6 @@
1
+ 1.5.1
2
+ * Bug Fix for hashes getting converted to arrays
3
+
1
4
  1.5.0
2
5
  * Better polymorphic support
3
6
  * Memoization of all lookups to stop repeats
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_cacheable (1.5.0)
4
+ simple_cacheable (1.5.1)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- cacheable
1
+ Simple Cacheable [![Build Status](https://travis-ci.org/flyerhzm/simple_cacheable.png?branch=master)](https://travis-ci.org/flyerhzm/simple_cacheable)
2
2
  =========
3
3
 
4
- cacheable is a simple cache implementation based on activerecord, it is
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 1.9.3 and 2.0.0 and works with jruby.
7
+ it supports activerecord >= 3.0.0, tested on 2.0.0 and works with jruby.
8
8
 
9
9
  Introduction
10
10
  ------------
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- simple_cacheable (1.4.1)
4
+ simple_cacheable (1.5.1)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- simple_cacheable (1.4.1)
4
+ simple_cacheable (1.5.1)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -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 !coder?(value) && value.respond_to?(:to_a)
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
- record = coder[:class].allocate
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
 
@@ -1,3 +1,3 @@
1
1
  module Cacheable
2
- VERSION = "1.5.0"
2
+ VERSION = "1.5.1"
3
3
  end
@@ -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 = {:foo => "Bar", :class => "batman"}
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.0
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-17 00:00:00.000000000 Z
12
+ date: 2014-01-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails