shadow_model 0.2.3 → 0.2.4

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: b6118254f3fd80b0d13fc35d08c4d42e32643bd2
4
- data.tar.gz: 3819fd775710ada5b404a1c99e989f62b05e9860
3
+ metadata.gz: a440b755047339d9c19cb083d67e6a850c1daf1b
4
+ data.tar.gz: 6f089365819678b32129e3e28a8b87cc5b13c6c7
5
5
  SHA512:
6
- metadata.gz: f97578fa62d8bc0f4287736a9cdb153976c44afbf87152fa1c13dc2a3c23c5b367fdfc33f8ea7a88295cce90d969746d5b21ec796a460301a1d73277f03d6839
7
- data.tar.gz: 60fb8cff7c9700d224f4b47045e78420aa0c6d28a41f20a9cf7456d2675e7bb9479c7d84009a5826190dda3384bb44b226d4ef6d28b4a4a50904a14e3718295e
6
+ metadata.gz: 37f50a5bae551d95d019f739abadddd804bc6ffe61dac2c62a16cf632c046d3ecddbf53e9b7c6ce85db8fc39035fa72bb5de39bfa451a3966b736932e212a86c
7
+ data.tar.gz: 7322e40d43c14aee65124ad30dd454a5bb6769dc2024f9ee3df7891e657e565ccedb7196b27d32642bfb760a201818fc490ff68b56811f1a7e9e21bd720b35bc
@@ -11,7 +11,7 @@ class ::ActiveRecord::Associations::Builder::HasMany
11
11
  def build_with_shadow_option
12
12
  reflection = build_without_shadow_option
13
13
  if options[:shadow]
14
- model_name = model.table_name.singularize
14
+ model_name = model.name.tr('::', '').underscore
15
15
  model.class_eval <<-RUBY
16
16
  def #{name}_shadow_cache_key
17
17
  "#{model_name}_\#{self[self.class.primary_key]}_#{name}_shadow_cache"
@@ -30,20 +30,20 @@ class ::ActiveRecord::Associations::Builder::HasMany
30
30
  RUBY
31
31
 
32
32
  reflection.klass.class_eval <<-RUBY
33
- after_save :update_shadow_cach_of_#{model_name}
34
- after_destroy :delete_shadow_cach_of_#{model_name}
33
+ after_save :update_shadow_cache_of_#{model_name}
34
+ after_destroy :delete_shadow_cache_of_#{model_name}
35
35
 
36
36
  def belongs_to_#{model_name}_shadow_cache_key
37
37
  "#{model_name}_\#{self[:#{reflection.foreign_key}]}_#{name}_shadow_cache"
38
38
  end
39
39
 
40
- def update_shadow_cach_of_#{model_name}
40
+ def update_shadow_cache_of_#{model_name}
41
41
  cache_key = belongs_to_#{model_name}_shadow_cache_key
42
42
  Redis.current.hset(cache_key, self[self.class.primary_key], self.build_shadow_data)
43
43
  update_expiration(cache_key)
44
44
  end
45
45
 
46
- def delete_shadow_cach_of_#{model_name}
46
+ def delete_shadow_cache_of_#{model_name}
47
47
  Redis.current.hdel(belongs_to_#{model_name}_shadow_cache_key, self[self.class.primary_key])
48
48
  end
49
49
  RUBY
@@ -1,3 +1,3 @@
1
1
  module ShadowModel
2
- VERSION = "0.2.3"
2
+ VERSION = "0.2.4"
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.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weihu Chen