Module: ActionDispatch::Flash::RequestMethods

Defined in:
actionpack/lib/action_dispatch/middleware/flash.rb

Instance Method Summary collapse

Instance Method Details

#commit_flashObject

:nodoc:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'actionpack/lib/action_dispatch/middleware/flash.rb', line 61

def commit_flash # :nodoc:
  session    = self.session || {}
  flash_hash = self.flash_hash

  if flash_hash && (flash_hash.present? || session.key?("flash"))
    session["flash"] = flash_hash.to_session_value
    self.flash = flash_hash.dup
  end

  if (!session.respond_to?(:loaded?) || session.loaded?) && # reset_session uses {}, which doesn't implement #loaded?
      session.key?("flash") && session["flash"].nil?
    session.delete("flash")
  end
end

#flashObject

Access the contents of the flash. Use flash["notice"] to read a notice you put there or flash["notice"] = "hello" to put a new one.



47
48
49
50
51
# File 'actionpack/lib/action_dispatch/middleware/flash.rb', line 47

def flash
  flash = flash_hash
  return flash if flash
  self.flash = Flash::FlashHash.from_session_value(session["flash"])
end

#flash=(flash) ⇒ Object



53
54
55
# File 'actionpack/lib/action_dispatch/middleware/flash.rb', line 53

def flash=(flash)
  set_header Flash::KEY, flash
end

#flash_hashObject

:nodoc:



57
58
59
# File 'actionpack/lib/action_dispatch/middleware/flash.rb', line 57

def flash_hash # :nodoc:
  get_header Flash::KEY
end

#reset_sessionObject

:nodoc:



76
77
78
79
# File 'actionpack/lib/action_dispatch/middleware/flash.rb', line 76

def reset_session # :nodoc:
  super
  self.flash = nil
end