提交 1a404abc 编写于 作者: S Sam Stephenson

Remove ActionView::Helpers::CacheHelper#fragment_cache_key

Introduced in e56c6354, `CacheHelper#fragment_cache_key` is a duplicate of `ActionController::Caching::Fragments#fragment_cache_key`.

We now require the view to provide this method on its own (as with `view_cache_dependencies`); `ActionController::Caching::Fragments` exports its version as a `helper_method`.
上级 dbf867cf
......@@ -14,6 +14,12 @@ module Caching
#
# expire_fragment('name_of_cache')
module Fragments
extend ActiveSupport::Concern
included do
helper_method :fragment_cache_key if respond_to?(:helper_method)
end
# Given a key (as described in +expire_fragment+), returns
# a key suitable for use in reading, writing, or expiring a
# cached fragment. All keys are prefixed with <tt>views/</tt> and uses
......
......@@ -216,14 +216,6 @@ def cache_fragment_name(name = {}, skip_digest: nil, virtual_path: nil)
end
end
# Given a key (as described in ActionController::Caching::Fragments.expire_fragment),
# returns a key suitable for use in reading, writing, or expiring a
# cached fragment. All keys are prefixed with <tt>views/</tt> and uses
# ActiveSupport::Cache.expand_cache_key for the expansion.
def fragment_cache_key(key)
ActiveSupport::Cache.expand_cache_key(key.is_a?(Hash) ? url_for(key).split("://").last : key, :views)
end
private
def fragment_name_with_digest(name, virtual_path) #:nodoc:
......
......@@ -9,6 +9,10 @@ def setup_view(paths)
@assigns = { :secret => 'in the sauce' }
@view = Class.new(ActionView::Base) do
def view_cache_dependencies; end
def fragment_cache_key(key)
ActiveSupport::Cache.expand_cache_key(key, :views)
end
end.new(paths, @assigns)
@controller_view = TestController.new.view_context
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册