view 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
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