Sha256: 355a0bf3b1011dd01cf49fcf9cd610b79840df5dfb464197b3c4f27f1202a403

Contents?: true

Size: 555 Bytes

Versions: 8

Compression:

Stored size: 555 Bytes

Contents

require 'active_support'

module CachedCounts
  module ActiveRecordBaseMethods
    extend ActiveSupport::Concern

    included do
      after_save    :clear_count_cache
      after_destroy :clear_count_cache

      class << self
        delegate :clear_count_cache, :count_with_caching, :length_with_caching,
          :size_with_caching, :count_without_caching, :length_without_caching,
          :size_without_caching, :to => :scoped
      end

      private

      def clear_count_cache
        self.class.clear_count_cache
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cached_counts-0.2.4 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.2.3 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.2.2 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.2.1 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.2.0 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.1.4 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.1.3 lib/cached_counts/active_record_base_methods.rb
cached_counts-0.1.2 lib/cached_counts/active_record_base_methods.rb