class Athena::HTTP::Session::FlashBag
inherits Reference
#
Stores flash messages, messages that are only meant to be shown to the user once, grouped by type.
E.g. "notice" or "error".
Reading messages via #get or #all removes them, while #peek and #peek_all leave them in place.
Included modules
Athena::HTTP::Session::BagInterface
Constructors#
Methods#
#add(type : String, message : String) : Nil#
Adds the provided message to those of the provided type.
#get(type : String, default : Array(String) = [] of String) : Array(String)#
Returns and removes the messages of the provided type, or returns the provided default if there are none.
#has?(type : String) : Bool#
Returns true if there are messages of the provided type, otherwise false.
#load(pull : JSON::PullParser | Nil) : Nil#
Loads this bag's data from the provided pull parser, positioned at the value persisted under #storage_key.
Resets this bag to empty if pull is nil, i.e. nothing was persisted under it.
#name : String#
Returns the name of this bag, used to retrieve it via AHTTP::Session#bag.
#peek(type : String, default : Array(String) = [] of String) : Array(String)#
Returns the messages of the provided type, or the provided default if there are none, without removing them.
#peek_all : Hash(String, Array(String))#
Returns the messages of all types, without removing them.
#set(type : String, messages : String | Array(String)) : Nil#
Replaces the messages of the provided type with the provided messages.
#set_all(messages : Hash(String, Array(String))) : Nil#
Replaces the messages of all types with the provided messages.
#storage_key : String#
Returns the key this bag's data is persisted under within the session.
#to_json(builder : JSON::Builder) : Nil#
Writes this bag's data to the provided builder, to be persisted under #storage_key.