mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Simplify lookup_store
I think allowing nested array parameters is almost useless.
This commit is contained in:
parent
1dac170c23
commit
fa986ae0ca
3 changed files with 4 additions and 4 deletions
|
@ -53,8 +53,7 @@ module ActiveSupport
|
||||||
#
|
#
|
||||||
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
|
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
|
||||||
# # => returns MyOwnCacheStore.new
|
# # => returns MyOwnCacheStore.new
|
||||||
def lookup_store(*store_option)
|
def lookup_store(store = nil, *parameters)
|
||||||
store, *parameters = *Array.wrap(store_option).flatten
|
|
||||||
|
|
||||||
case store
|
case store
|
||||||
when Symbol
|
when Symbol
|
||||||
|
|
|
@ -56,7 +56,7 @@ module Rails
|
||||||
# Initialize cache early in the stack so railties can make use of it.
|
# Initialize cache early in the stack so railties can make use of it.
|
||||||
initializer :initialize_cache, group: :all do
|
initializer :initialize_cache, group: :all do
|
||||||
unless Rails.cache
|
unless Rails.cache
|
||||||
Rails.cache = ActiveSupport::Cache.lookup_store(config.cache_store)
|
Rails.cache = ActiveSupport::Cache.lookup_store(*config.cache_store)
|
||||||
|
|
||||||
if Rails.cache.respond_to?(:middleware)
|
if Rails.cache.respond_to?(:middleware)
|
||||||
config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware)
|
config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware)
|
||||||
|
|
|
@ -239,9 +239,10 @@ module ApplicationTests
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Rails.cache does not respond to middleware" do
|
test "Rails.cache does not respond to middleware" do
|
||||||
add_to_config "config.cache_store = :memory_store"
|
add_to_config "config.cache_store = :memory_store, { timeout: 10 }"
|
||||||
boot!
|
boot!
|
||||||
assert_equal "Rack::Runtime", middleware[5]
|
assert_equal "Rack::Runtime", middleware[5]
|
||||||
|
assert_instance_of ActiveSupport::Cache::MemoryStore, Rails.cache
|
||||||
end
|
end
|
||||||
|
|
||||||
test "Rails.cache does respond to middleware" do
|
test "Rails.cache does respond to middleware" do
|
||||||
|
|
Loading…
Reference in a new issue