1
0
Fork 0
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:
Kasper Timm Hansen 2015-09-06 17:42:57 +02:00
parent 143d047d65
commit 379ddf54c0

View file

@ -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: