jbuilder
https://github.com/rails/jbuilder
Ruby
Jbuilder: generate JSON objects with a Builder-style DSL
JbuilderTemplate#cache_if!
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
endEdit
git clone [email protected]:rails/jbuilder.git
cd jbuilder
open lib/jbuilder/jbuilder_template.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-JbuilderTemplate-cache_if--for-pr
# Commit to gitgit add lib/jbuilder/jbuilder_template.rbgit commit -m "better docs for JbuilderTemplate#cache_if!"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-JbuilderTemplate-cache_if--for-pr
hub pull-request
# Celebrate!