instance method
cache_if!
Ruby on Rails 2.12.0
Since v2.4.1 Last seen in v2.14.1Signature
cache_if!(condition, *args, &block)
Conditionally caches the json depending in the condition given as first parameter. Has the same signature as the cache helper method in ActionView::Helpers::CacheHelper and so can be used in the same way.
Example:
json.cache_if! !admin?, @person, expires_in: 10.minutes do json.extract! @person, :name, :age end
Parameters
-
conditionreq -
argsrest -
blockblock
Source
# File lib/jbuilder/jbuilder_template.rb, line 109
def cache_if!(condition, *args, &block)
condition ? cache!(*args, &block) : yield
end
Defined in lib/jbuilder/jbuilder_template.rb line 109
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in JbuilderTemplate