annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
94
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
1 # stolen from https://github.com/rails/rails/pull/25616
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
2
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
3 if Gem::Version.new(Rails.version) >= Gem::Version.new("5.1.0")
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
4 raise "remove this monkey patch!"
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
5 end
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
6
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
7 module ActionView::CollectionCaching
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
8 private def collection_by_cache_keys
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
9 seed =
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
10 if @options[:cached].respond_to?(:call)
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
11 @options[:cached]
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
12 else
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
13 ->(i) { i }
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
14 end
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
15
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
16 @collection.each_with_object({}) do |item, hash|
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
17 hash[expanded_cache_key(seed.call(item))] = item
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
18 end
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
19 end
0c8a8b390145 Now with epic caching
nanaya <me@myconan.net>
parents:
diff changeset
20 end