module Sinatra::RedirectWithFlash

Constants

COMMON_FLASH_NAMES

Public Instance Methods

redirect(uri, *args) click to toggle source
Calls superclass method
# 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