module CounterCulture::Extensions
Private Instance Methods
Source
# File lib/counter_culture/extensions.rb, line 108 def _update_counts_after_create self.class.after_commit_counter_cache.each do |counter| # increment counter cache counter.change_counter_cache(self, :increment => true) end end
called by after_create callback
Source
# File lib/counter_culture/extensions.rb, line 116 def _update_counts_after_destroy self.class.after_commit_counter_cache.each do |counter| unless destroyed? # decrement counter cache counter.change_counter_cache(self, :increment => false) end end end
called by after_destroy callback
Source
# File lib/counter_culture/extensions.rb, line 126 def _update_counts_after_update self.class.after_commit_counter_cache.each do |counter| # figure out whether the applicable counter cache changed (this can happen # with dynamic column names) counter_cache_name_was = counter.counter_cache_name_for(counter.previous_model(self)) counter_cache_name = counter.counter_cache_name_for(self) if counter.first_level_relation_changed?(self) || (counter.delta_column && counter.attribute_changed?(self, counter.delta_column)) || counter_cache_name != counter_cache_name_was # increment the counter cache of the new value counter.change_counter_cache(self, :increment => true, :counter_column => counter_cache_name) # decrement the counter cache of the old value counter.change_counter_cache(self, :increment => false, :was => true, :counter_column => counter_cache_name_was) end end end
called by after_update callback
Source
# File lib/counter_culture/extensions.rb, line 146 def destroyed_for_counter_culture? if respond_to?(:paranoia_destroyed?) paranoia_destroyed? elsif defined?(Discard::Model) && self.class.include?(Discard::Model) discarded? else false end end
check if record is soft-deleted