shadow_model 0.1.0 → 0.1.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: af8efdd8209465e2f3160872a3ebd70d13386b66
4
- data.tar.gz: 5a95826af5c3f28814fa974c5348972ce0d475ba
3
+ metadata.gz: e3c9efb64ff1507c2a3bb52cfdb0f3cb5170cc11
4
+ data.tar.gz: eac4e8e566f6b430673ca18eaa331884e79558b4
5
5
  SHA512:
6
- metadata.gz: 57371ab38d192ab2eefc309ddf9d24fa7020e627196016371e58c930e26cbdf508b776c40e714a3d937187b8e07a8820943f18ce4a86a6e19d6fb57d5e352ee5
7
- data.tar.gz: 5187008742137a1ca9f641f2946adbf01bdd9d2e69e726fee007fd9684fc956368944e9147e2cdcaec044c301bb80126b27efe2f0d03c9b6ff0f07d05f071f0f
6
+ metadata.gz: ec6a1e6e66cdc55c9968882310e01884d70ab59c2e5072cbc4146431636b0661aeaf1762f5ea6dd13839f118c6dc9dae9edf957ccd037fdf8e8d7f6be4c30f73
7
+ data.tar.gz: 05815242f6983486b71d5a1b98b9f24c491f9242540d1dcefb6d0f4d4eb94e6424c31462c4b94dcca32f1a8ee8331b7b2700fea4ed9d794bbaf2089e45372d7f
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  A rails plugin use redis to cache models data.
4
4
 
5
- [![Build Status](https://travis-ci.org/cctiger36/shadow_model.png?branch=master)](https://travis-ci.org/cctiger36/shadow_model)
5
+ [![Build Status](https://travis-ci.org/cctiger36/shadow_model.png?branch=master)](https://travis-ci.org/cctiger36/shadow_model) [![Gem Version](https://badge.fury.io/rb/shadow_model.png)](http://badge.fury.io/rb/shadow_model) [![Coverage Status](https://coveralls.io/repos/cctiger36/shadow_model/badge.png)](https://coveralls.io/r/cctiger36/shadow_model) [![Code Climate](https://codeclimate.com/github/cctiger36/shadow_model.png)](https://codeclimate.com/github/cctiger36/shadow_model)
6
6
 
7
7
  ## Installation
8
8
 
@@ -29,11 +29,11 @@ And use this to retrieve the model from redis.
29
29
  <table>
30
30
  <tr>
31
31
  <td>expiration</td><td>Set the timeout of each cache.</td>
32
- <tr>
33
32
  </tr>
33
+ <tr>
34
34
  <td>&nbsp;&nbsp;update_expiration</td><td>Reset cache expiration after model updated.</td>
35
35
  </tr>
36
- </tr>
36
+ <tr>
37
37
  <td>expireat</td><td>Set the absolute timeout timestamp of each cache.</td>
38
38
  </tr>
39
39
  </table>
@@ -42,12 +42,12 @@ module ShadowModel
42
42
  end
43
43
 
44
44
  def update_expiration
45
- if self.class.shadow_options[:expiration].present?
45
+ if expiration = self.class.shadow_options[:expiration]
46
46
  if self.class.shadow_options[:update_expiration] || shadow_ttl < 0
47
- Redis.current.expire(shadow_cache_key, self.class.shadow_options[:expiration])
47
+ Redis.current.expire(shadow_cache_key, expiration)
48
48
  end
49
- elsif self.class.shadow_options[:expireat].present?
50
- Redis.current.expireat(shadow_cache_key, self.class.shadow_options[:expireat].to_i) if shadow_ttl < 0
49
+ elsif expireat = self.class.shadow_options[:expireat]
50
+ Redis.current.expireat(shadow_cache_key, expireat.to_i) if shadow_ttl < 0
51
51
  end
52
52
  end
53
53
 
@@ -67,6 +67,7 @@ module ShadowModel
67
67
  @shadow_methods << arg.to_sym
68
68
  end
69
69
  end
70
+ @shadow_attributes << primary_key.to_sym if !@shadow_attributes.include?(primary_key.to_sym)
70
71
  @shadow_attributes.each { |attr| define_shadow_attributes(attr) }
71
72
  end
72
73
 
@@ -1,3 +1,3 @@
1
1
  module ShadowModel
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shadow_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weihu Chen