class Marten::HTTP::FlashStore
- Marten::HTTP::FlashStore
- Reference
- Object
Overview
Represents a flash messages store.
This store provides a way to pass basic string messages from one handler to another. Any string value that is set in this store will be available to the next handler processing the next request, and then it will be cleared out.
Included Modules
- Enumerable({String, String})
- Marten::Template::Object
Defined in:
marten/http/flash_store.crmarten/template/ext/http/flash_store.cr
Constructors
Class Method Summary
-
.from_session(session : Session::Store::Base)
Allows to initialize a flash store from a session store.
Instance Method Summary
-
#[](key : String | Symbol)
Returns the message for the passed
key
, or raises aKeyError
exception if not found. -
#[]=(key : String | Symbol, value : String)
Allows to set a flash message for a given
key
. -
#[]?(key : String | Symbol)
Returns the message for the passed
key
, ornil
if not found. -
#clear
Clears the flash store and returns it.
-
#delete(key : String | Symbol)
Deletes the message for the passed
key
and returns its value, otherwise returnsnil
. -
#delete(key : String | Symbol, &block)
Deletes the message for the passed
key
and returns its value, or calls a block with the key when not found. -
#discard(key : Nil | String | Symbol = nil)
Discards all the flash messages or either one specific flash message key by the end of the current request.
-
#each(*args, **options)
Iterates over all the flash messages in the current store.
-
#each(*args, **options, &)
Iterates over all the flash messages in the current store.
-
#empty?(*args, **options)
Returns
true
if the flash store is empty. -
#empty?(*args, **options, &)
Returns
true
if the flash store is empty. -
#fetch(key : String | Symbol, default)
Returns the message for the passed
key
, or the passeddefault
if not found. -
#fetch(key : String | Symbol, &)
Returns the message for the passed
key
, or calls a block with the key when not found. -
#has_key?(key : String | Symbol)
Returns
true
if a message associated with the passedkey
exists. -
#keep(key : Nil | String | Symbol = nil)
Keeps all the flash messages or either one specific flash message key for the next request.
-
#persist(session : Session::Store::Base) : Nil
Persists the content of the current flash store into the passed session store.
-
#size(*args, **options)
Returns the size of the flash store.
-
#size(*args, **options, &)
Returns the size of the flash store.
Constructor Detail
Class Method Detail
Allows to initialize a flash store from a session store.
Flash session values that were previously set (likely by the flash middleware) will be used to populate the new flash store.
Instance Method Detail
Returns the message for the passed key
, or raises a KeyError
exception if not found.
Deletes the message for the passed key
and returns its value, otherwise returns nil
.
Deletes the message for the passed key
and returns its value, or calls a block with the key when not found.
Discards all the flash messages or either one specific flash message key by the end of the current request.
Returns the message for the passed key
, or the passed default
if not found.
Returns the message for the passed key
, or calls a block with the key when not found.
Returns true
if a message associated with the passed key
exists.
Keeps all the flash messages or either one specific flash message key for the next request.
Persists the content of the current flash store into the passed session store.