module ActAsCached::ActiveRecord::FinderMethods

Public Class Methods

included(base) click to toggle source
# File lib/act_as_cached/active_record/finder_methods.rb, line 4
def self.included(base)
  base.class_eval do
    alias_method_chain :find,:act_as_cached
  end
end

Public Instance Methods

cache_mod() click to toggle source
# File lib/act_as_cached/active_record/finder_methods.rb, line 23
def cache_mod
  klass.cache_mod
end
find_with_act_as_cached(*args) click to toggle source

Only support find with primary_key are currently supported.

# File lib/act_as_cached/active_record/finder_methods.rb, line 11
def find_with_act_as_cached(*args)
  options = args.extract_options!
  if args.length == 1 && enabled_cache? && where_values.blank?
    # TODO
    path = [cache_mod.name,args[0]].join('/')
    cache_mod.fetch_cache(path) { find_without_act_as_cached(args[0]) }
  else
    args << options
    find_without_act_as_cached(*args)
  end
end