redis_permalink 0.0.3 → 0.0.4
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 +8 -8
- data/lib/redis_permalink/version.rb +2 -2
- data/lib/redis_permalink.rb +10 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTcyY2RhZTQxNzRkMTZiZTAyN2I2OGRkNzU5MWIyNDk2OWRmZDc1NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YzdmNGZhNjVmZDhkODA5NmRiNzdjNGIzYjk0MjBmNTFiYjRkZDk5OQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDAwODg0MjI2ZWM4ODk4MmJhZTRhNTljYjFlOGViODAxMDgyZjBlMzRlMGE2
|
10
|
+
NGM4NTBiNmU5MzI5ZDQyOGQxYWY0YTZiYTM1MjQ1NTE3MjExYTA3NTRlZTY4
|
11
|
+
ZWE5Y2E2ZTIxMzFhOGU3ZTQxNGE1MDFkNTY1NTE2ZTJmMTFlZTU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OWI4ZGNmZjg2YjI3MzNkMzU5MDEyMWI4YmY4MWZmMTE0NmQwMWI1MzIyZTc5
|
14
|
+
MjM5MWM1ZmVmYjdlZjBiYzNkNWU1YzE3MjNlODlhY2NmNmZlNTM3MTcxNDdk
|
15
|
+
NTYwN2ZjNzIxMTllNmFjOThiYzRjYjBlNTA3YTJlOGE2MThkMDA=
|
@@ -1,3 +1,3 @@
|
|
1
1
|
module RedisPermalink
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.4"
|
3
|
+
end
|
data/lib/redis_permalink.rb
CHANGED
@@ -7,7 +7,7 @@ module RedisPermalink
|
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
def redis_permalink_name
|
10
|
-
|
10
|
+
@redis_permalink_name
|
11
11
|
end
|
12
12
|
|
13
13
|
def redis_permalink_name=(v)
|
@@ -27,8 +27,12 @@ module RedisPermalink
|
|
27
27
|
self.redis_permalink_cache = cache
|
28
28
|
|
29
29
|
class_eval do
|
30
|
+
def redis_permalink_field
|
31
|
+
self[self.class.redis_permalink_name]
|
32
|
+
end
|
33
|
+
|
30
34
|
def generate_permalink
|
31
|
-
list = self.
|
35
|
+
list = self.redis_permalink_field.split(/ /)
|
32
36
|
|
33
37
|
refined = []
|
34
38
|
list.size.times.each do |i|
|
@@ -51,20 +55,20 @@ module RedisPermalink
|
|
51
55
|
end
|
52
56
|
|
53
57
|
def self.via_permalink(perma)
|
54
|
-
if self.redis_permalink_cache
|
58
|
+
if self.class.redis_permalink_cache
|
55
59
|
key = "#{self.name.underscore}:#{perma}"
|
56
|
-
id = self.redis_permalink_cache.get(key)
|
60
|
+
id = self.class.redis_permalink_cache.get(key)
|
57
61
|
return self.find(id) if id
|
58
62
|
end
|
59
63
|
|
60
64
|
# If not cached
|
61
65
|
obj = self.find_by_permalink(perma)
|
62
|
-
self.redis_permalink_cache.set(key, obj.id) if self.redis_permalink_cache
|
66
|
+
self.class.redis_permalink_cache.set(key, obj.id) if self.class.redis_permalink_cache
|
63
67
|
return obj
|
64
68
|
end
|
65
69
|
|
66
70
|
before_create { self['permalink'] = self.generate_permalink }
|
67
|
-
after_destroy { self.redis_permalink_cache.del(self['permalink']) if self.redis_permalink_cache }
|
71
|
+
after_destroy { self.class.redis_permalink_cache.del(self['permalink']) if self.class.redis_permalink_cache }
|
68
72
|
end
|
69
73
|
end
|
70
74
|
end
|