redis_object 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 +4 -4
- data/lib/redis_object/base.rb +12 -9
- data/lib/redis_object/keys.rb +2 -2
- data/lib/redis_object/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9e5ca5eeb648940280fd12e10eadde8060bf9bd
|
4
|
+
data.tar.gz: aa70d17724344acd63d808113f31449fe0da257b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e24ee1ccdaa8cc5171a0d58ba3ebebad051cf361dbd719f954837427d1b9d5d69a5c7cfcc9b23103c25fe5aa57a2779035a1b2e6d78d5f956e9ce42351a2d7ce
|
7
|
+
data.tar.gz: 57b3a7698aa66d95faa01f88e83dd65d75a5160b8c722160215de280ddc8ca44cf0e839afb20e2f6249ad77be48f2384cac3d7b8fa56d6da57816cfa13e92635
|
data/lib/redis_object/base.rb
CHANGED
@@ -2,7 +2,7 @@ module Seabright
|
|
2
2
|
module ObjectBase
|
3
3
|
|
4
4
|
def initialize(ident={})
|
5
|
-
if ident && (ident.class == String || (ident.class == Symbol && (ident = ident.to_s)))
|
5
|
+
if ident && (ident.class == String || (ident.class == Symbol && (ident = ident.to_s)))
|
6
6
|
load(ident.dup)
|
7
7
|
elsif ident && ident.class == Hash
|
8
8
|
ident[id_sym] ||= generate_id
|
@@ -25,23 +25,22 @@ module Seabright
|
|
25
25
|
self.class.reserve(k)
|
26
26
|
end
|
27
27
|
|
28
|
-
# oved this to the dumper module in experimental - remove when it gets to base
|
29
|
-
# def to_json
|
30
|
-
# Yajl::Encoder.encode(actual)
|
31
|
-
# end
|
32
|
-
|
33
28
|
def id
|
34
29
|
@id || get(id_sym) || set(id_sym, generate_id)
|
35
30
|
end
|
36
31
|
|
37
32
|
def load(o_id)
|
38
|
-
@id = o_id
|
33
|
+
@id = clean_id(o_id)
|
39
34
|
true
|
40
35
|
end
|
41
36
|
|
37
|
+
def clean_id(i)
|
38
|
+
self.class.clean_id(i)
|
39
|
+
end
|
40
|
+
|
42
41
|
def save
|
43
42
|
set(:class, self.class.name)
|
44
|
-
set(id_sym,id
|
43
|
+
set(id_sym,clean_id(id))
|
45
44
|
set(:key, key)
|
46
45
|
store.sadd(self.class.plname, key)
|
47
46
|
store.del(reserve_key)
|
@@ -217,6 +216,10 @@ module Seabright
|
|
217
216
|
|
218
217
|
module ClassMethods
|
219
218
|
|
219
|
+
def clean_id(i)
|
220
|
+
i.to_s.gsub(/.*:/,'').gsub(/_h$/,'')
|
221
|
+
end
|
222
|
+
|
220
223
|
def generate_id
|
221
224
|
v = new_id
|
222
225
|
while exists?(v) do
|
@@ -260,7 +263,7 @@ module Seabright
|
|
260
263
|
|
261
264
|
def recollect!
|
262
265
|
store.keys("#{name}:*_h").each do |ky|
|
263
|
-
store.sadd(plname,ky
|
266
|
+
store.sadd(plname, clean_id(ky))
|
264
267
|
end
|
265
268
|
end
|
266
269
|
|
data/lib/redis_object/keys.rb
CHANGED
@@ -2,7 +2,7 @@ module Seabright
|
|
2
2
|
module Keys
|
3
3
|
|
4
4
|
def key(ident = id)
|
5
|
-
"#{self.class.cname}:#{ident
|
5
|
+
"#{self.class.cname}:#{clean_id(ident)}"
|
6
6
|
end
|
7
7
|
|
8
8
|
def reserve_key(ident = id)
|
@@ -20,7 +20,7 @@ module Seabright
|
|
20
20
|
module ClassMethods
|
21
21
|
|
22
22
|
def key(ident=nil)
|
23
|
-
"#{cname}#{ident ? ":#{ident
|
23
|
+
"#{cname}#{ident ? ":#{clean_id(ident)}" : ""}"
|
24
24
|
end
|
25
25
|
|
26
26
|
def reserve_key(ident=nil)
|
data/lib/redis_object/version.rb
CHANGED