aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/activejob.gemspec
diff options
context:
space:
mode:
authorclaudiob <claudiob@gmail.com>2015-01-06 12:14:49 -0800
committerclaudiob <claudiob@gmail.com>2015-02-10 17:08:44 -0800
commit050fda020606028acffeaaf79e65d6f595856262 (patch)
treeadd7803df4e0ccf2b53c1ea8bd25ab19b952d79c /activejob/activejob.gemspec
parent17d9996c91918df4c32b8ed7c67c2bbe715cfc9d (diff)
downloadrails-050fda020606028acffeaaf79e65d6f595856262.tar.gz
rails-050fda020606028acffeaaf79e65d6f595856262.tar.bz2
rails-050fda020606028acffeaaf79e65d6f595856262.zip
Accept a collection in fresh_when and stale?
The methods `fresh_when` and `stale?` from ActionController::ConditionalGet accept a single record as a short form for a hash. For instance ```ruby def show @article = Article.find(params[:id]) fresh_when(@article) end ``` is just a short form for: ```ruby def show @article = Article.find(params[:id]) fresh_when(etag: @article, last_modified: @article.created_at) end ``` This commit extends `fresh_when` and `stale?` to also accept a collection of records, so that a short form similar to the one above can be used in an `index` action. After this commit, the following code: ```ruby def index @article = Article.all fresh_when(etag: @articles, last_modified: @articles.maximum(:created_at)) end ``` can be simply written as: ```ruby def index @article = Article.all fresh_when(@articles) end ```
Diffstat (limited to 'activejob/activejob.gemspec')
0 files changed, 0 insertions, 0 deletions