Sha256: cc37a3ee2653ab3766dae918af3d06061a873240f4cc14f9a946ac8ea4722f9b

Contents?: true

Size: 613 Bytes

Versions: 11

Compression:

Stored size: 613 Bytes

Contents

require 'active_support'

module CachedCounts
  module ActiveRecordRelationMethods
    extend ActiveSupport::Concern

    included do
      alias_method_chain :count,  :caching
      alias_method_chain :length, :caching
      alias_method_chain :size,   :caching
    end

    def count_with_caching(*args)
      CachedCounts::Cache.new(self).count
    end

    def length_with_caching(*args)
      CachedCounts::Cache.new(self).count
    end

    def size_with_caching(*args)
      CachedCounts::Cache.new(self).count
    end

    def clear_count_cache
      CachedCounts::Cache.new(self).clear
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cached_counts-0.2.5 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.2.4 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.2.3 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.2.2 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.2.1 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.2.0 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.1.4 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.1.3 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.1.2 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.1.1 lib/cached_counts/active_record_relation_methods.rb
cached_counts-0.1.0 lib/cached_counts/active_record_relation_methods.rb