module ThreeD::ClassMethodCache::InstanceMethods
Public Instance Methods
cache_attribute!(att, value)
click to toggle source
# File lib/three_d/class_method_cache.rb, line 165 def cache_attribute!(att, value) m = self.method_cache.merge!(att.to_s => value) #self.personal_status.update_attributes(:method_cache => m) # => not using DB anymore return value end
cached?(att)
click to toggle source
# File lib/three_d/class_method_cache.rb, line 157 def cached?(att) !self.method_cache[att.to_s].nil? end
cached_attribute(att)
click to toggle source
# File lib/three_d/class_method_cache.rb, line 161 def cached_attribute(att) self.method_cache[att.to_s] end
clear_method_cache(meths = [], options = {})
click to toggle source
Clear methods. Kann ein Methodenname, ein Array von Namen oder ein Regexp sein
# File lib/three_d/class_method_cache.rb, line 174 def clear_method_cache(meths = [], options = {}) if meths.is_a?(Regexp) meths = self.method_cache.keys.select {|k| !k.match(meths).nil? } elsif meths.is_a?(Symbol) || meths.is_a?(String) meths = self.class.cached_methods[meths.to_sym] elsif !meths.is_a?(Array) meths = meths.to_a end begin c = self.method_cache meths_all = c.keys meths_valid = [] meths.each do |m| meths_all.each do |mv| meths_valid << mv if mv.match(m) end end CachingLog.info meths_valid.inspect meths_valid.each do |m| CachingLog.info "DELETE cache data: #{m}" CachingLog.info " for #{self.personal_data.first_name} #{self.personal_data.last_name}" c.delete(m) end rescue # wenn was schief läuft: $user_method_caching für den user auf {} setzen CachingLog.info "RESET CACHE (forced): #{self.full_name} / #{self.id}" self.class.cache_storage[self.id] = {} end end
method_cache()
click to toggle source
# File lib/three_d/class_method_cache.rb, line 140 def method_cache m = self.class.cache_storage[self.id] if m.nil? # Wenn neue nutzer angelegt werden CachingLog.info "Create cache for #{self.class.name}(#{self.id})" self.class.cache_storage.merge!(self.id => {}) self.class.cache_storage[self.id] return {} else return m end end
method_cache=(val)
click to toggle source
# File lib/three_d/class_method_cache.rb, line 153 def method_cache=(val) self.class.cache_storage.merge!(self.id => val) end
reset_cache()
click to toggle source
# File lib/three_d/class_method_cache.rb, line 205 def reset_cache self.class.cache_storage[self.id] = {} end