lib/jbuilder/jbuilder_template.rb in jbuilder-2.0.2 vs lib/jbuilder/jbuilder_template.rb in jbuilder-2.0.3
- old
+ new
@@ -48,11 +48,11 @@
# json.cache! ['v1', @person], expires_in: 10.minutes do
# json.extract! @person, :name, :age
# end
def cache!(key=nil, options={}, &block)
if @context.controller.perform_caching
- value = ::Rails.cache.fetch(_cache_key(key), options) do
+ value = ::Rails.cache.fetch(_cache_key(key, options), options) do
_scope { yield self }
end
merge! value
else
@@ -81,14 +81,14 @@
def _render_partial(options)
options[:locals].merge! json: self
@context.render options
end
- def _cache_key(key)
+ def _cache_key(key, options)
if @context.respond_to?(:cache_fragment_name)
# Current compatibility, fragment_name_with_digest is private again and cache_fragment_name
# should be used instead.
- @context.cache_fragment_name(key)
+ @context.cache_fragment_name(key, options)
elsif @context.respond_to?(:fragment_name_with_digest)
# Backwards compatibility for period of time when fragment_name_with_digest was made public.
@context.fragment_name_with_digest(key)
else
::ActiveSupport::Cache.expand_cache_key(key.is_a?(::Hash) ? url_for(key).split('://').last : key, :jbuilder)