mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add commit method to share option normalization
Remove the clutter to make PermanentCookieJar's one change stand out.
This commit is contained in:
parent
143d047d65
commit
379ddf54c0
1 changed files with 12 additions and 4 deletions
|
@ -422,19 +422,27 @@ module ActionDispatch
|
|||
def [](name)
|
||||
@parent_jar[name.to_s]
|
||||
end
|
||||
end
|
||||
|
||||
class PermanentCookieJar < AbstractCookieJar # :nodoc:
|
||||
def []=(name, options)
|
||||
if options.is_a?(Hash)
|
||||
options.symbolize_keys!
|
||||
else
|
||||
options = { :value => options }
|
||||
options = { value: options }
|
||||
end
|
||||
|
||||
options[:expires] = 20.years.from_now
|
||||
commit(options)
|
||||
@parent_jar[name] = options
|
||||
end
|
||||
|
||||
private
|
||||
def commit(options); end
|
||||
end
|
||||
|
||||
class PermanentCookieJar < AbstractCookieJar # :nodoc:
|
||||
private
|
||||
def commit(options)
|
||||
options[:expires] = 20.years.from_now
|
||||
end
|
||||
end
|
||||
|
||||
class JsonSerializer # :nodoc:
|
||||
|
|
Loading…
Reference in a new issue