class Roda::RodaPlugins::Flash::FlashHash
Simple flash hash, where assiging to the hash updates the flash used in the following request.
Attributes
next[R]
The flash hash for the next request. This is what gets written to by []=
.
Public Class Methods
new(hash={})
click to toggle source
Setup the next hash when initializing, and handle treat nil as a new empty hash.
Calls superclass method
# File lib/roda/plugins/flash.rb, line 41 def initialize(hash={}) super(hash||{}) @next = {} end
Public Instance Methods
[]=(k, v)
click to toggle source
Update the next hash with the given key and value.
# File lib/roda/plugins/flash.rb, line 47 def []=(k, v) @next[k] = v end
discard(key=(no_arg=true))
click to toggle source
Remove given key from the next hash, or clear the next hash if no argument is given.
# File lib/roda/plugins/flash.rb, line 53 def discard(key=(no_arg=true)) if no_arg @next.clear else @next.delete(key) end end
keep(key=(no_arg=true))
click to toggle source
Copy the entry with the given key from the current hash to the next hash, or copy all entries from the current hash to the next hash if no argument is given.
# File lib/roda/plugins/flash.rb, line 64 def keep(key=(no_arg=true)) if no_arg @next.merge!(self) else self[key] = self[key] end end
sweep()
click to toggle source
Replace the current hash with the next hash and clear the next hash.
# File lib/roda/plugins/flash.rb, line 73 def sweep replace(@next) @next.clear self end