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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24c6d1f461aa94f27fe6c79750dc3e1b1fcb8120
4
- data.tar.gz: b6739ea7fde6bff76edbed5377882cfe196c46ff
3
+ metadata.gz: b9e5ca5eeb648940280fd12e10eadde8060bf9bd
4
+ data.tar.gz: aa70d17724344acd63d808113f31449fe0da257b
5
5
  SHA512:
6
- metadata.gz: b4cada8b2e40e5391667c19ae39ce4f7e1131a0e59951bb6d0c665212b78781493d878cb034c60ced5751da3c4d6e7b5bce0c4b86bf7e73dc11f425e9208ba1c
7
- data.tar.gz: 995c5f452bc853e98e59f5791b345830d0af7b38d8a09266a83ee9234b12afe53d739744a5c307358232277b523e1a31c6c89151bedbf98f1221b2e56eacb716
6
+ metadata.gz: e24ee1ccdaa8cc5171a0d58ba3ebebad051cf361dbd719f954837427d1b9d5d69a5c7cfcc9b23103c25fe5aa57a2779035a1b2e6d78d5f956e9ce42351a2d7ce
7
+ data.tar.gz: 57b3a7698aa66d95faa01f88e83dd65d75a5160b8c722160215de280ddc8ca44cf0e839afb20e2f6249ad77be48f2384cac3d7b8fa56d6da57816cfa13e92635
@@ -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)))# && ident.gsub!(/.*:/,'') && ident.length > 0
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.gsub(/.*:/,''))
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.gsub(/_h$/,''))
266
+ store.sadd(plname, clean_id(ky))
264
267
  end
265
268
  end
266
269
 
@@ -2,7 +2,7 @@ module Seabright
2
2
  module Keys
3
3
 
4
4
  def key(ident = id)
5
- "#{self.class.cname}:#{ident.gsub(/^.*:/,'').gsub(/_h$/,'')}"
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.gsub(/^.*:/,'').gsub(/_h$/,'')}" : ""}"
23
+ "#{cname}#{ident ? ":#{clean_id(ident)}" : ""}"
24
24
  end
25
25
 
26
26
  def reserve_key(ident=nil)
@@ -1,5 +1,5 @@
1
1
  module Seabright
2
2
  class RedisObject
3
- VERSION = "1.5.0"
3
+ VERSION = "1.5.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis_object
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
  - John Bragg