提交 c43ca06c 编写于 作者: J Julian Vargas

Code cleanup for ActionDispatch::Flash#call

The nested `if` was replaced by using `presence` which takes account for
the given hash when it is `nil` or when it is empty. The `else` was
removed because what it was doing was to assign to `env[KEY]` the
value it already had.
上级 2519fb0e
......@@ -243,15 +243,9 @@ def call(env)
session = Request::Session.find(env) || {}
flash_hash = env[KEY]
if flash_hash
if !flash_hash.empty? || session.key?('flash')
session["flash"] = flash_hash.to_session_value
new_hash = flash_hash.dup
else
new_hash = flash_hash
end
env[KEY] = new_hash
if flash_hash.present? || session.key?('flash')
session["flash"] = flash_hash.to_session_value
env[KEY] = flash_hash.dup
end
if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册