Module: Cash::WriteThrough::InstanceMethods
- Defined in:
- lib/cash/write_through.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_to_caches ⇒ Object
- #expire_caches ⇒ Object
- #remove_from_caches ⇒ Object
- #shallow_clone ⇒ Object
- #update_caches ⇒ Object
Class Method Details
.included(active_record_class) ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/cash/write_through.rb', line 13 def self.included(active_record_class) active_record_class.class_eval do after_create :add_to_caches after_update :update_caches after_destroy :remove_from_caches end end |
Instance Method Details
#add_to_caches ⇒ Object
21 22 23 |
# File 'lib/cash/write_through.rb', line 21 def add_to_caches InstanceMethods.unfold(self.class, :add_to_caches, self) end |
#expire_caches ⇒ Object
34 35 36 |
# File 'lib/cash/write_through.rb', line 34 def expire_caches InstanceMethods.unfold(self.class, :expire_caches, self) end |
#remove_from_caches ⇒ Object
29 30 31 32 |
# File 'lib/cash/write_through.rb', line 29 def remove_from_caches return if new_record? InstanceMethods.unfold(self.class, :remove_from_caches, self) end |
#shallow_clone ⇒ Object
38 39 40 41 42 43 |
# File 'lib/cash/write_through.rb', line 38 def shallow_clone clone = self.class.new clone.instance_variable_set("@attributes", instance_variable_get(:@attributes)) clone.instance_variable_set("@new_record", new_record?) clone end |
#update_caches ⇒ Object
25 26 27 |
# File 'lib/cash/write_through.rb', line 25 def update_caches InstanceMethods.unfold(self.class, :update_caches, self) end |