class

Marten::HTTP::FlashStore

Inherits Marten::Template::Object / Marten::Template::CanDefineTemplateAttributes / Enumerable / Reference / Object

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.

Constructors

new(flashes : Hash(String, String) = {} of String => String, discard : Array(String) = [] of String)
Source

Class methods

from_session(session : Session::Store::Base)

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.

Source

Instance methods

[](key : String | Symbol)

Returns the message for the passed key, or raises a KeyError exception if not found.

Source
[]=(key : String | Symbol, value : String)

Allows to set a flash message for a given key.

Source
[]?(key : String | Symbol)

Returns the message for the passed key, or nil if not found.

Source
clear

Clears the flash store and returns it.

Source
delete(key : String | Symbol)

Deletes the message for the passed key and returns its value, otherwise returns nil.

Source
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.

Source
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.

Source
each(*args, **options)

Iterates over all the flash messages in the current store.

Source
each(*args, **options, &)

Iterates over all the flash messages in the current store.

Source
empty?(*args, **options)

Returns true if the flash store is empty.

Source
empty?(*args, **options, &)

Returns true if the flash store is empty.

Source
fetch(key : String | Symbol, default)

Returns the message for the passed key, or the passed default if not found.

Source
fetch(key : String | Symbol, &)

Returns the message for the passed key, or calls a block with the key when not found.

Source
has_key?(key : String | Symbol)

Returns true if a message associated with the passed key exists.

Source
keep(key : Nil | String | Symbol = nil)

Keeps all the flash messages or either one specific flash message key for the next request.

Source
persist(session : Session::Store::Base) : Nil

Persists the content of the current flash store into the passed session store.

Source
size(*args, **options)

Returns the size of the flash store.

Source
size(*args, **options, &)

Returns the size of the flash store.

Source