Module: Sinatra::Flash::Storage
- Defined in:
- lib/sinatra/flash/storage.rb
Instance Method Summary collapse
-
#flash(key = :flash) ⇒ FlashHash
The main Sinatra helper for accessing the flash.
Instance Method Details
#flash(key = :flash) ⇒ FlashHash
The main Sinatra helper for accessing the flash. You can have multiple flash collections (e.g., for different apps in your Rack stack) by passing a symbol to it.
you want to reference. Defaults to ‘:flash’. If there is no session or the key is not found, an empty hash is used. Note that this is only used in the case of multiple flash collections, which is rarer than multiple flash messages.
16 17 18 19 |
# File 'lib/sinatra/flash/storage.rb', line 16 def flash(key=:flash) @flash ||= {} @flash[key.to_sym] ||= FlashHash.new((session ? session[key.to_sym] : {})) end |