comparison config/initializers/monkeypatch_collection_cache_key_callable.rb @ 94:0c8a8b390145

Now with epic caching And kicking out builder because I can't figure out how to cache it ;_;
author nanaya <me@myconan.net>
date Thu, 28 Jul 2016 03:49:08 +0900
parents
children
comparison
equal deleted inserted replaced
93:5cc4aab05c55 94:0c8a8b390145
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