From 18dd16caeb272c1f09cf6c5c64b5a65bdb773296 Mon Sep 17 00:00:00 2001 From: Mike Perham Date: Sat, 28 Aug 2010 14:46:15 -0700 Subject: [PATCH] Issue #5486 Dynamic cache store support --- activesupport/lib/active_support/cache.rb | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb index 8153dd5..9519c66 100644 --- a/activesupport/lib/active_support/cache.rb +++ b/activesupport/lib/active_support/cache.rb @@ -58,7 +58,17 @@ module ActiveSupport case store when Symbol store_class_name = store.to_s.camelize - store_class = ActiveSupport::Cache.const_get(store_class_name) + store_class = nil + begin + store_class = ActiveSupport::Cache.const_get(store_class_name) + rescue NameError + begin + require "active_support/cache/#{store.to_s}" + store_class = ActiveSupport::Cache.const_get(store_class_name) + rescue LoadError + raise "Could not find cache store adapter for #{store.to_s} (#{$!})" + end + end store_class.new(*parameters) when nil ActiveSupport::Cache::MemoryStore.new -- 1.7.1