Method: ActionDispatch::Request::Session#update

Defined in:
actionpack/lib/action_dispatch/request/session.rb

#update(hash) ⇒ Object Also known as: merge!

Updates the session with given Hash.

session.to_hash
# => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2"}

session.update({ "foo" => "bar" })
# => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}

session.to_hash
# => {"session_id"=>"e29b9ea315edf98aad94cc78c34cc9b2", "foo" => "bar"}


183
184
185
186
187
188
189
190
# File 'actionpack/lib/action_dispatch/request/session.rb', line 183

def update(hash)
  unless hash.respond_to?(:to_hash)
    raise TypeError, "no implicit conversion of #{hash.class.name} into Hash"
  end

  load_for_write!
  @delegate.update hash.to_hash.stringify_keys
end