Movatterモバイル変換


[0]ホーム

URL:


Skip to ContentSkip to Search
Ruby on Rails 8.1.1

Class ActionDispatch::Flash::FlashHash<Object

v8.1.1
Methods
#
A
C
D
E
I
K
N
S
T
Included Modules

Instance Public methods

[](k)Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 169def[](k)@flashes[k.to_s]end

[]=(k, v)Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 163def[]=(k,v)k =k.to_s@discard.deletek@flashes[k] =vend

alert()Link

Convenience accessor forflash[:alert].

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 280defalertself[:alert]end

alert=(message)Link

Convenience accessor forflash[:alert]=.

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 285defalert=(message)self[:alert] =messageend

clear()Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 204defclear@discard.clear@flashes.clearend

delete(key)Link

Immediately deletes the single flash entry. Use this method when you want remove the message within the current action. See alsodiscard.

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 189defdelete(key)key =key.to_s@discard.deletekey@flashes.deletekeyselfend

discard(k = nil)Link

Marks the entire flash or a single flash entry to be discarded by the end of the current action:

flash.discard# discard the entire flash at the end of the current actionflash.discard(:warning)# discard only the "warning" entry at the end of the current action

Use this method when you want to display the message in the current action but not in the next one. See alsodelete.

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 264defdiscard(k =nil)k =k.to_sifk@discard.mergeArray(k||keys)k?self[k]:selfend

each(&block)Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 209defeach(&block)@flashes.each(&block)end

empty?()Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 200defempty?@flashes.empty?end

initialize_copy(other)Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 155definitialize_copy(other)ifother.now_is_loaded?@now =other.now.dup@now.flash =selfendsuperend

keep(k = nil)Link

Keeps either the entire current flash or a specific flash entry available for the next action:

flash.keep# keeps the entire flashflash.keep(:notice)# keeps only the "notice" entry, the rest of the flash is discarded

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 250defkeep(k =nil)k =k.to_sifk@discard.subtractArray(k||keys)k?self[k]:selfend

key?(name)Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 183defkey?(name)@flashes.key?name.to_send

keys()Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 179defkeys@flashes.keysend

notice()Link

Convenience accessor forflash[:notice].

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 290defnoticeself[:notice]end

notice=(message)Link

Convenience accessor forflash[:notice]=.

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 295defnotice=(message)self[:notice] =messageend

now()Link

Sets a flash that will not be available to the next action, only to the current.

flash.now[:message] ="Hello current action"

This method enables you to use the flash as a central messaging system in your app. When you need to pass an object to the next action, you use the standard flash assign ([]=). When you need to pass an object to the current action, you usenow, and your object will vanish when the current action is done.

Entries set vianow are accessed the same way as standard entries:flash['my-key'].

Also, brings two convenience accessors:

flash.now.alert ="Beware now!"# Equivalent to flash.now[:alert] = "Beware now!"flash.now.notice ="Good luck now!"# Equivalent to flash.now[:notice] = "Good luck now!"

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 241defnow@now||=FlashNow.new(self)end

to_hash()Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 196defto_hash@flashes.dupend

Instance Protected methods

now_is_loaded?()Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 300defnow_is_loaded?@nowend

Instance Private methods

stringify_array(array)Link

Source:show |on GitHub

# File actionpack/lib/action_dispatch/middleware/flash.rb, line 305defstringify_array(array)# :doc:array.mapdo|item|item.kind_of?(Symbol)?item.to_s:itemendend

[8]ページ先頭

©2009-2025 Movatter.jp