Module: ActsAsCached::Mixin

Defined in:
lib/cache_fu.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_cached(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cache_fu.rb', line 22

def acts_as_cached(options = {})
  extend  ClassMethods
  include InstanceMethods

  options.symbolize_keys!

  # convert the find_by shorthand
  if find_by = options.delete(:find_by)
    options[:finder]   = "find_by_#{find_by}".to_sym
    options[:cache_id] = find_by
  end

  cache_config.replace  options.reject { |key,| not ActsAsCached.valued_keys.include? key }
  cache_options.replace options.reject { |key,| ActsAsCached.valued_keys.include? key }
end