From ff29606c061099f82668ab62e50660cda8645512 Mon Sep 17 00:00:00 2001 From: Carlhuda Date: Thu, 4 Mar 2010 16:50:57 -0800 Subject: Refactor cache_store to use ActionController config --- actionpack/lib/action_controller/caching.rb | 34 ++++++++++++---------- .../lib/action_controller/metal/compatibility.rb | 5 ---- 2 files changed, 18 insertions(+), 21 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index d784138ebe..7fae4e924d 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -40,15 +40,27 @@ module ActionController #:nodoc: autoload :Sweeping, 'action_controller/caching/sweeping' end - included do - @@cache_store = nil - cattr_reader :cache_store + module ConfigMethods + def cache_store + config.cache_store + end - # Defines the storage option for cached fragments - def self.cache_store=(store_option) - @@cache_store = ActiveSupport::Cache.lookup_store(store_option) + def cache_store=(store) + config.cache_store = ActiveSupport::Cache.lookup_store(store) end + private + + def cache_configured? + perform_caching && cache_store + end + end + + include ConfigMethods + + included do + extend ConfigMethods + include Pages, Actions, Fragments include Sweeping if defined?(ActiveRecord) @@ -56,11 +68,6 @@ module ActionController #:nodoc: cattr_accessor :perform_caching end - module ClassMethods - def cache_configured? - perform_caching && cache_store - end - end def caching_allowed? request.get? && response.status == 200 @@ -75,10 +82,5 @@ module ActionController #:nodoc: yield end end - - private - def cache_configured? - self.class.cache_configured? - end end end diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index 44ace925e9..317a9fd951 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -35,11 +35,6 @@ module ActionController raise env["action_dispatch.rescue.exception"] end - # Defines the storage option for cached fragments - def cache_store=(store_option) - @@cache_store = ActiveSupport::Cache.lookup_store(store_option) - end - self.page_cache_directory = defined?(Rails.public_path) ? Rails.public_path : "" end -- cgit v1.2.3