redis_object 1.2.8 → 1.2.9b

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OTNlOTliYThhMzE3MGY1MTI4YmU4MDhkN2IxODVmNGZhOTRmZjc3Yg==
4
+ MWVlY2YyOTg0YmVlOGI1ZTdhODI4YzUwYjVjZmFmMTI1YTZkY2RmMg==
5
5
  data.tar.gz: !binary |-
6
- Y2Y1ZWU1MWQ1ZjQyNjJkNWUyYWFlYThlNjE4MzVkNWFiOWU2ZGFmOA==
6
+ YTUxMGRmMDQ2MGZkN2ZjYmUyZjgyZTUxYTU1ZWVhYjcwYjI2YjhmNg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NGZjYWQwMzc5NTQxNDQ5NDE0OWJmNDI3MmUwYmNjOGRjNjdjOTQ0MTZiNTk4
10
- Y2M3NGVmNjAyYzZlNzRjZWU3MDRlOGRjNzYyNzJmYzcxNTFkYTVmMGM5ODVj
11
- MzU3MDgxZDY3NzI1NWFjZGFmYWRhNTc3NzQ2ZDJhZjAyNWUzMTE=
9
+ MDY5OTFhNmE2YzRmZDhmMzc3M2ExZDgwNzg3ZGY1OTdjNzc0NzM1MjQxODFl
10
+ NDBiMTRkYmM3MjAyYzg4MGYwNzYzMjhiOTViMmM3ZjlhODdjYjBiOGFlODQz
11
+ ZjcxYmNiYWYzMmM0YjI0NmM4Y2MzZGE5MTBlM2JiYjIxNzgzZmY=
12
12
  data.tar.gz: !binary |-
13
- YTgwYTMyM2Y3ZmZiYzZmYTgzODBmMDY4MTI1YjkwMzRhMTBiZjk4YWNkNWMx
14
- NDRhZGZkNzIzMzk3ZDRmMTcyNDFmMmYzYzIwNTg2OTQwYTA2NWU3YjI4ZTZk
15
- NGE0YzcxOWY2MTllOGYzOTM4NzBmNTk5ZTk4ZDMxYTJmYmEyMTg=
13
+ YjQyMTBjMzBlZmIyNGEwZDAxNzlmMjNkMmM5ODllZDM5MmMxYmU5ODFmMmRj
14
+ ZjA1Y2RhNDYzNmRiOTcyMjEwMTYyNzNlYmQ3ZjMxOGU0NzA1YmVmYWZjM2Qx
15
+ MjBmODlhYjBiYzE3OTk0OThjNzI2YmU2MmJlOTJlYmIxYjA3NTY=
@@ -10,7 +10,7 @@
10
10
  # invalidate_upstream Property, Application, PaymentRequest, PaymentResponse
11
11
  #
12
12
  # Notify some objects in my collections when I am updated: (objects in these collections)
13
- # invalidate_downstream :properties, :applications, :payment_requests, :payment_responses
13
+ # invalidate_downstream Property, Application, PaymentRequest, PaymentResponse
14
14
  #
15
15
  # You can also set up hooks for when this object is updated by certain types of objects by defining the following:
16
16
  # def invalidated_by(obj,chain)
@@ -139,6 +139,7 @@ module Seabright
139
139
  return unless invalidations(:up).size > 0
140
140
  puts "Invalidating upstream: #{invalidations(:up).inspect}" if Debug.verbose?
141
141
  backreferences.each do |obj|
142
+ obj = Object.const_get(obj) if obj.is_a?(String) or obj.is_a?(Symbol)
142
143
  if invalidations(:up).include?(obj.class) and obj.respond_to?(:invalidated_by_other)
143
144
  obj.invalidated_by_other(self,invalidation_chain + [self.hkey])
144
145
  end
@@ -241,7 +242,20 @@ module Seabright
241
242
  # end
242
243
 
243
244
  def invalidate_downstream(*args)
244
- @downstream_invalidations = (@downstream_invalidations || []) + args
245
+ @downstream_invalidations = (@downstream_invalidations || []) + convert_to_collection_names(args)
246
+ end
247
+
248
+ def convert_to_collection_names(names)
249
+ names.map do |name|
250
+ case name
251
+ when RedisObject
252
+ name.collection_name
253
+ when String, Symbol
254
+ name.to_s.pluralize.underscore.to_sym
255
+ else
256
+ name
257
+ end
258
+ end
245
259
  end
246
260
 
247
261
  def downstream_invalidations
@@ -49,13 +49,13 @@ module Seabright
49
49
  end
50
50
  end
51
51
  end
52
-
52
+
53
53
  def rename_class old_name, new_name
54
54
  old_name = old_name.to_s#.split('::').last
55
55
  new_name = new_name.to_s#.split('::').last
56
56
  old_collection_name = old_name.split('::').last.underscore.pluralize
57
57
  new_collection_name = new_name.split('::').last.underscore.pluralize
58
-
58
+
59
59
  # references to type in collection data
60
60
  keys("#{old_name}:*:backreferences").each do |backref_key|
61
61
  smembers(backref_key).each do |hashref|
@@ -70,7 +70,7 @@ module Seabright
70
70
  zadd(new_collection, score, key.sub(/^#{old_name}/, new_name))
71
71
  end
72
72
  del(old_collection)
73
-
73
+
74
74
  # this updates the lists of collection names
75
75
  collection_names = "#{hashref}:collections"
76
76
  smembers(collection_names).each do |collection_name|
@@ -82,7 +82,7 @@ module Seabright
82
82
  end
83
83
  rename(backref_key, backref_key.sub(/^#{old_name}/, new_name))
84
84
  end
85
-
85
+
86
86
  # type-wide id index
87
87
  smembers(old_name.pluralize).each do |key|
88
88
  sadd(new_name.pluralize, key.sub(/^#{old_name}/, new_name))
@@ -94,7 +94,7 @@ module Seabright
94
94
  hset("#{key}_h", RedisObject.id_sym(new_name), key.sub(/^#{old_name}:/,''))
95
95
  end
96
96
  del(old_name.pluralize)
97
-
97
+
98
98
  # column indexes
99
99
  keys("#{old_name.pluralize}::*").each do |old_index|
100
100
  new_index = old_index.sub(/^#{old_name.pluralize}/, new_name.pluralize)
@@ -103,7 +103,7 @@ module Seabright
103
103
  end
104
104
  del(old_index)
105
105
  end
106
-
106
+
107
107
  # top-level keys
108
108
  keys("#{old_name}:*").each do |key|
109
109
  rename(key, key.sub(/^#{old_name}/, new_name))
@@ -115,4 +115,4 @@ module Seabright
115
115
 
116
116
  end
117
117
  end
118
- end
118
+ end
@@ -1,5 +1,5 @@
1
1
  module Seabright
2
2
  class RedisObject
3
- VERSION = "1.2.8"
3
+ VERSION = "1.2.9b"
4
4
  end
5
5
  end
@@ -38,6 +38,12 @@ module ViewCachingSpec
38
38
 
39
39
  end
40
40
 
41
+ class OtherContainer < RedisObject
42
+
43
+ invalidate_downstream TypedObject
44
+
45
+ end
46
+
41
47
  class Baby < RedisObject
42
48
 
43
49
  invalidate_upstream TypedObject
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.2.8
4
+ version: 1.2.9b
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Bragg
@@ -161,9 +161,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
161
161
  version: 1.9.2
162
162
  required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ! '>'
165
165
  - !ruby/object:Gem::Version
166
- version: '0'
166
+ version: 1.3.1
167
167
  requirements: []
168
168
  rubyforge_project: redis_object
169
169
  rubygems_version: 2.0.3