Module: LogicalModel::Cache::InstanceMethods
- Defined in:
- lib/logical_model/cache.rb
Instance Attribute Summary collapse
-
#loaded_at ⇒ Object
Returns the value of attribute loaded_at.
Instance Method Summary collapse
- #_destroy(params = {}) ⇒ Object
- #_destroy_with_cache(params = {}) ⇒ Object
- #_save ⇒ Object
- #_save_with_cache ⇒ Object
- #_update(params = {}) ⇒ Object
- #_update_with_cache(params = {}) ⇒ Object
- #delete_cached ⇒ Object
- #initialize_loaded_at ⇒ Object
Instance Attribute Details
#loaded_at ⇒ Object
Returns the value of attribute loaded_at.
13 14 15 |
# File 'lib/logical_model/cache.rb', line 13 def loaded_at @loaded_at end |
Instance Method Details
#_destroy(params = {}) ⇒ Object
39 40 41 |
# File 'lib/logical_model/cache.rb', line 39 def _destroy(params={}) super end |
#_destroy_with_cache(params = {}) ⇒ Object
43 44 45 46 |
# File 'lib/logical_model/cache.rb', line 43 def _destroy_with_cache(params={}) delete_cached _destroy_without_cache end |
#_save ⇒ Object
19 20 21 |
# File 'lib/logical_model/cache.rb', line 19 def _save super end |
#_save_with_cache ⇒ Object
23 24 25 26 |
# File 'lib/logical_model/cache.rb', line 23 def _save_with_cache delete_cached _save_without_cache end |
#_update(params = {}) ⇒ Object
29 30 31 |
# File 'lib/logical_model/cache.rb', line 29 def _update(params={}) super end |
#_update_with_cache(params = {}) ⇒ Object
33 34 35 36 |
# File 'lib/logical_model/cache.rb', line 33 def _update_with_cache(params={}) delete_cached _update_without_cache params end |
#delete_cached ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/logical_model/cache.rb', line 49 def delete_cached model_name = self.class.to_s.pluralize.underscore self.class.logger.debug "LogicalModel Log CACHE: Delete cache for #{model_name}\/#{self.id}-.*" # Delete cached models self.class.cache_store.delete_matched(/#{model_name}\/#{self.id}-.*/) if self.class.respond_to?(:belongs_to_keys) && !self.class.belongs_to_keys.blank? # If it belongs to another model (or models) self.class.belongs_to_keys.each do |association_name, association_class| model_name = association_class.to_s.pluralize.underscore self.class.logger.debug "LogicalModel Log CACHE: Delete cache for #{model_name}\/#{self.send("#{association_name}_id")}-.*" # Delete cached models self.class.cache_store.delete_matched(/#{model_name}\/#{self.send("#{association_name}_id")}-.*/) end end end |
#initialize_loaded_at ⇒ Object
15 16 17 |
# File 'lib/logical_model/cache.rb', line 15 def initialize_loaded_at self.loaded_at = Time.now end |