提交 a2035307 编写于 作者: C Carlos Antonio da Silva

Use merge! to merge additional options onto default options

上级 dcc68fa4
......@@ -22,7 +22,7 @@ module ClassMethods
#
# class InvoicesController < ApplicationController
# etag { current_user.try :id }
#
#
# def show
# # Etag will differ even for the same invoice when it's viewed by a different current_user
# @invoice = Invoice.find(params[:id])
......@@ -71,7 +71,7 @@ def fresh_when(record_or_options, additional_options = {})
options.assert_valid_keys(:etag, :last_modified, :public)
else
record = record_or_options
options = { etag: record, last_modified: record.try(:updated_at) }.merge(additional_options)
options = { etag: record, last_modified: record.try(:updated_at) }.merge!(additional_options)
end
response.etag = combine_etags(options[:etag]) if options[:etag]
......@@ -162,8 +162,7 @@ def expires_in(seconds, options = {}) #:doc:
def expires_now #:doc:
response.cache_control.replace(:no_cache => true)
end
private
def combine_etags(etag)
[ etag, *etaggers.map { |etagger| instance_exec(&etagger) }.compact ]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册