Mercurial > rsstweet
view 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 |
line wrap: on
line source
# stolen from https://github.com/rails/rails/pull/25616 if Gem::Version.new(Rails.version) >= Gem::Version.new("5.1.0") raise "remove this monkey patch!" end module ActionView::CollectionCaching private def collection_by_cache_keys seed = if @options[:cached].respond_to?(:call) @options[:cached] else ->(i) { i } end @collection.each_with_object({}) do |item, hash| hash[expanded_cache_key(seed.call(item))] = item end end end