Module: ActionDispatch::Flash::RequestMethods

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

Instance Method Summary collapse

Instance Method Details

#commit_flashObject

:nodoc:


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

def commit_flash # :nodoc:
  return unless session.enabled?

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

  if session.loaded? && session.key?("flash") && session["flash"].nil?
    session.delete("flash")
  end
end

#flashObject

Access the contents of the flash. Returns a ActionDispatch::Flash::FlashHash.

See ActionDispatch::Flash for example usage.


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

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

#flash=(flash) ⇒ Object


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

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

#flash_hashObject

:nodoc:


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

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

#reset_sessionObject

:nodoc:


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

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