Mercurial > rsstweet
annotate config/initializers/monkeypatch_collection_cache_key_callable.rb @ 95:dfd7daac110e
Simpler syntax because I can
author | nanaya <me@myconan.net> |
---|---|
date | Thu, 28 Jul 2016 03:56:56 +0900 |
parents | 0c8a8b390145 |
children |
rev | line source |
---|---|
94 | 1 # stolen from https://github.com/rails/rails/pull/25616 |
2 | |
3 if Gem::Version.new(Rails.version) >= Gem::Version.new("5.1.0") | |
4 raise "remove this monkey patch!" | |
5 end | |
6 | |
7 module ActionView::CollectionCaching | |
8 private def collection_by_cache_keys | |
9 seed = | |
10 if @options[:cached].respond_to?(:call) | |
11 @options[:cached] | |
12 else | |
13 ->(i) { i } | |
14 end | |
15 | |
16 @collection.each_with_object({}) do |item, hash| | |
17 hash[expanded_cache_key(seed.call(item))] = item | |
18 end | |
19 end | |
20 end |