Module: Sinatra::RedirectWithFlash
- Defined in:
- lib/sinatra/redirect_with_flash.rb
Constant Summary collapse
- COMMON_FLASH_NAMES =
[:notice, :alert, :warning, :error, :info, :success]
Instance Method Summary collapse
Instance Method Details
#redirect(uri, *args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sinatra/redirect_with_flash.rb', line 7 def redirect(uri, *args) flash_opts = args.last if flash_opts && flash_opts.is_a?(Hash) COMMON_FLASH_NAMES.each do |name| if val = flash_opts.delete(name) flash[name] = val end end if other_flashes = flash_opts.delete(:flash) other_flashes.each {|k, v| flash[k] = v} end end super(uri, *args) end |