flagpole_sitta 0.9.7 → 0.9.7.1

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.
@@ -205,8 +205,13 @@ module FlagpoleSitta
205
205
  Rails.cache.clear
206
206
  Rails.logger.error("CACHE FAILURE @BEFORE STATE CHANGE CACHE IS BEING NUKED :: FLAGPOLE_SITTA")
207
207
  Rails.logger.error(e.message)
208
- e.backtrace.inspect.each do |b|
209
- Rails.logger.error(b)
208
+ e.backtrace.each do |b|
209
+ Rails.logger.error("\t" + b.to_s)
210
+ end
211
+ puts "CACHE FAILURE @BEFORE STATE CHANGE CACHE IS BEING NUKED :: FLAGPOLE_SITTA"
212
+ puts e.message
213
+ e.backtrace.each do |b|
214
+ puts "\t" + b.to_s
210
215
  end
211
216
  end
212
217
 
@@ -232,8 +237,13 @@ module FlagpoleSitta
232
237
  Rails.cache.clear
233
238
  Rails.logger.error("CACHE FAILURE @AFTER_SAVE CACHE IS BEING NUKED :: FLAGPOLE_SITTA")
234
239
  Rails.logger.error(e.message)
235
- e.backtrace.inspect.each do |b|
236
- Rails.logger.error(b)
240
+ e.backtrace.each do |b|
241
+ Rails.logger.error("\t" + b.to_s)
242
+ end
243
+ puts "CACHE FAILURE @AFTER_SAVE CACHE IS BEING NUKED :: FLAGPOLE_SITTA"
244
+ puts e.message
245
+ e.backtrace.each do |b|
246
+ puts "\t" + b.to_s
237
247
  end
238
248
  end
239
249
  end
@@ -172,75 +172,92 @@ module FlagpoleSitta
172
172
 
173
173
  #Updates the 'hash' on save of any of its records.
174
174
  def update_existence_hash alive
175
- #Get the Current Class and the Old Class in case the object changed classes.
176
- #If its the base object, ie type is nil, then return class as the old_clazz.
177
- #If the object doesn't have the type field assume it can't change classes.
178
- new_clazz = self.has_attribute?('type') ? (self.type || self.class.to_s) : self.class.to_s
179
- old_clazz = self.has_attribute?('type') ? (self.type_was || self.class.to_s) : self.class.to_s
180
- superclazz = self.class.get_super_with_existence_hash
181
175
 
182
- #Old key is where it was, and new is where it is going.
183
- new_key = new_clazz.respond_to?(:constantize) ? self.send("#{new_clazz.constantize.route_id}") : nil
184
- old_key = old_clazz.respond_to?(:constantize) ? self.send("#{old_clazz.constantize.route_id}_was") : nil
176
+ begin
177
+ #Get the Current Class and the Old Class in case the object changed classes.
178
+ #If its the base object, ie type is nil, then return class as the old_clazz.
179
+ #If the object doesn't have the type field assume it can't change classes.
180
+ new_clazz = self.has_attribute?('type') ? (self.type || self.class.to_s) : self.class.to_s
181
+ old_clazz = self.has_attribute?('type') ? (self.type_was || self.class.to_s) : self.class.to_s
182
+ superclazz = self.class.get_super_with_existence_hash
185
183
 
186
- new_main_key = superclazz.eh_key_gen new_key, :class => new_clazz
187
- old_main_key = superclazz.eh_key_gen old_key, :class => old_clazz
184
+ #Old key is where it was, and new is where it is going.
185
+ new_key = new_clazz.respond_to?(:constantize) ? self.send("#{new_clazz.constantize.route_id}") : nil
186
+ old_key = old_clazz.respond_to?(:constantize) ? self.send("#{old_clazz.constantize.route_id}_was") : nil
188
187
 
189
- flag_key = superclazz.eh_key_gen "Flag"
190
- flag = FlagpoleSitta::CommonFs.flagpole_cache_read(flag_key)
188
+ new_main_key = superclazz.eh_key_gen new_key, :class => new_clazz
189
+ old_main_key = superclazz.eh_key_gen old_key, :class => old_clazz
191
190
 
192
- if flag.nil?
193
- flag = self.class.initialize_existence_hash
194
- end
195
-
196
- #If its a new record add it to the 'hash'
197
- if self.new_record?
198
- flag[:count] = flag[:count] + 1
199
- #if there are empty containers use them
200
- if flag[:empty] > -1
201
- #Find any empty container to use by popping it off of the top of the "stack".
202
- empty_key = superclazz.eh_key_gen flag[:empty], :emptystack => true
203
- i = FlagpoleSitta::CommonFs.flagpole_cache_read(empty_key)
204
- #Sense its going to be used remove its reference from the Stack.
205
- FlagpoleSitta::CommonFs.flagpole_cache_delete(empty_key)
206
- #Update the empty on flag to now hit the newest none used container on the stack.
207
- flag[:empty] = flag[:empty] - 1
208
- #Else add a space to the end.
191
+ flag_key = superclazz.eh_key_gen "Flag"
192
+ flag = FlagpoleSitta::CommonFs.flagpole_cache_read(flag_key)
193
+
194
+ if flag.nil?
195
+ flag = self.class.initialize_existence_hash
196
+ end
197
+
198
+ #If its a new record add it to the 'hash'
199
+ if self.new_record?
200
+ flag[:count] = flag[:count] + 1
201
+ #if there are empty containers use them
202
+ if flag[:empty] > -1
203
+ #Find any empty container to use by popping it off of the top of the "stack".
204
+ empty_key = superclazz.eh_key_gen flag[:empty], :emptystack => true
205
+ i = FlagpoleSitta::CommonFs.flagpole_cache_read(empty_key)
206
+ #Sense its going to be used remove its reference from the Stack.
207
+ FlagpoleSitta::CommonFs.flagpole_cache_delete(empty_key)
208
+ #Update the empty on flag to now hit the newest none used container on the stack.
209
+ flag[:empty] = flag[:empty] - 1
210
+ #Else add a space to the end.
211
+ else
212
+ #AR - update the array's end point
213
+ flag[:space] = flag[:space] + 1
214
+ i = flag[:space]
215
+ end
216
+ hash = {:type => new_clazz, :num => self.has_attribute?('num') ? (self.num || 0) : 0, :pos => i}
217
+ #If its an already existing record them get its existence hash, and then remove it from the cache.
209
218
  else
210
- #AR - update the array's end point
211
- flag[:space] = flag[:space] + 1
212
- i = flag[:space]
219
+ hash = FlagpoleSitta::CommonFs.flagpole_cache_read(old_main_key)
220
+ hash[:type] = new_clazz
213
221
  end
214
- hash = {:type => new_clazz, :num => self.has_attribute?('num') ? (self.num || 0) : 0, :pos => i}
215
- #If its an already existing record them get its existence hash, and then remove it from the cache.
216
- else
217
- hash = FlagpoleSitta::CommonFs.flagpole_cache_read(old_main_key)
218
- hash[:type] = new_clazz
219
- end
220
222
 
221
- array_main_key = superclazz.eh_key_gen hash[:pos]
223
+ array_main_key = superclazz.eh_key_gen hash[:pos]
222
224
 
223
- #Before new info gets written make sure to delete all the old records just in case. The New location before it gets used too.
224
- FlagpoleSitta::CommonFs.flagpole_cache_delete(new_main_key)
225
- FlagpoleSitta::CommonFs.flagpole_cache_delete(old_main_key)
226
- FlagpoleSitta::CommonFs.flagpole_cache_delete(array_main_key)
225
+ #Before new info gets written make sure to delete all the old records just in case. The New location before it gets used too.
226
+ FlagpoleSitta::CommonFs.flagpole_cache_delete(new_main_key)
227
+ FlagpoleSitta::CommonFs.flagpole_cache_delete(old_main_key)
228
+ FlagpoleSitta::CommonFs.flagpole_cache_delete(array_main_key)
227
229
 
228
- #If the record is not being destroyed add new route_id to existence hash
229
- if alive
230
- FlagpoleSitta::CommonFs.flagpole_cache_write(new_main_key, hash)
231
- FlagpoleSitta::CommonFs.flagpole_cache_write(array_main_key, {:type => new_clazz, :key => new_key})
232
- else
233
- if hash[:pos] == flag[:space]
234
- flag[:space] = flag[:space] - 1
230
+ #If the record is not being destroyed add new route_id to existence hash
231
+ if alive
232
+ FlagpoleSitta::CommonFs.flagpole_cache_write(new_main_key, hash)
233
+ FlagpoleSitta::CommonFs.flagpole_cache_write(array_main_key, {:type => new_clazz, :key => new_key})
235
234
  else
236
- flag[:empty] = flag[:empty] + 1
237
- empty_key = superclazz.eh_key_gen flag[:empty], :emptystack => true
238
- FlagpoleSitta::CommonFs.flagpole_cache_write(empty_key, hash[:pos])
235
+ if hash[:pos] == flag[:space]
236
+ flag[:space] = flag[:space] - 1
237
+ else
238
+ flag[:empty] = flag[:empty] + 1
239
+ empty_key = superclazz.eh_key_gen flag[:empty], :emptystack => true
240
+ FlagpoleSitta::CommonFs.flagpole_cache_write(empty_key, hash[:pos])
241
+ end
242
+ flag[:count] = flag[:count] - 1
239
243
  end
240
- flag[:count] = flag[:count] - 1
241
- end
242
244
 
243
- FlagpoleSitta::CommonFs.flagpole_cache_write(flag_key, flag)
245
+ FlagpoleSitta::CommonFs.flagpole_cache_write(flag_key, flag)
246
+ rescue Exception => e
247
+ #Keep ending up with one of the array objects having a key of nil. Despite the fact that it would have to at least start with /view
248
+ #becuase of the way its set up in the helper. If that happens all bets are off and just clear everything.
249
+ Rails.cache.clear
250
+ Rails.logger.error("EXISTANCE HASH FAILURE CACHE IS BEING NUKED :: FLAGPOLE_SITTA")
251
+ Rails.logger.error(e.message)
252
+ e.backtrace.each do |b|
253
+ Rails.logger.error("\t" + b.to_s)
254
+ end
255
+ puts "EXISTANCE HASH FAILURE CACHE IS BEING NUKED :: FLAGPOLE_SITTA"
256
+ puts e.message
257
+ e.backtrace.each do |b|
258
+ puts "\t" + b.to_s
259
+ end
260
+ end
244
261
 
245
262
  end
246
263
 
@@ -1,3 +1,3 @@
1
1
  module FlagpoleSitta
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.7.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flagpole_sitta
3
3
  version: !ruby/object:Gem::Version
4
- hash: 53
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 9
9
9
  - 7
10
- version: 0.9.7
10
+ - 1
11
+ version: 0.9.7.1
11
12
  platform: ruby
12
13
  authors:
13
14
  - Andrew Rove (Rover)