method

fetch

fetch(key, default = Unspecified, &block)
public

Returns value of the given key from the session, or raises `KeyError` if can’t find the given key and no default value is set. Returns default value if specified.

session.fetch(:foo)
# => KeyError: key not found: "foo"

session.fetch(:foo, :bar)
# => :bar

session.fetch(:foo) do
  :bar
end
# => :bar