Module: RecordCache::InstanceMethods

Defined in:
lib/record_cache.rb

Instance Method Summary collapse

Instance Method Details

#attr_was(attr) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/record_cache.rb', line 54

def attr_was(attr)
  attr = attr.to_s
  if ['id', 'type'].include?(attr) or not attribute_changed?(attr)
    read_attribute(attr)
  else
    changed_attributes[attr]
  end
end

#complete_deferred_record_cache_invalidationsObject



48
49
50
51
52
# File 'lib/record_cache.rb', line 48

def complete_deferred_record_cache_invalidations
  self.class.each_cached_index do |index|
    index.complete_deferred
  end
end

#invalidate_record_cacheObject



34
35
36
37
38
39
# File 'lib/record_cache.rb', line 34

def invalidate_record_cache
  self.class.each_cached_index do |index|
    index.invalidate_model(self)
    index.clear_deferred
  end
end

#invalidate_record_cache_deferredObject



41
42
43
44
45
46
# File 'lib/record_cache.rb', line 41

def invalidate_record_cache_deferred
  self.class.each_cached_index do |index|
    # Have to invalidate both before and after commit.
    index.invalidate_model(self)
  end
end