Skip to content

Commit

Permalink
Simplify lookup_store
Browse files Browse the repository at this point in the history
I think allowing nested array parameters is almost useless.
  • Loading branch information
kamipo committed Feb 5, 2020
1 parent 1dac170 commit fa986ae
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions activesupport/lib/active_support/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ class << self
#
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
# # => returns MyOwnCacheStore.new
def lookup_store(*store_option)
store, *parameters = *Array.wrap(store_option).flatten
def lookup_store(store = nil, *parameters)

case store
when Symbol
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/application/bootstrap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module Bootstrap
# Initialize cache early in the stack so railties can make use of it.
initializer :initialize_cache, group: :all do
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)
config.middleware.insert_before(::Rack::Runtime, Rails.cache.middleware)
Expand Down
3 changes: 2 additions & 1 deletion railties/test/application/middleware_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ def app
end

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!
assert_equal "Rack::Runtime", middleware[5]
assert_instance_of ActiveSupport::Cache::MemoryStore, Rails.cache
end

test "Rails.cache does respond to middleware" do
Expand Down

0 comments on commit fa986ae

Please sign in to comment.