- #
- A
- C
- D
- E
- I
- K
- N
- S
- T
实例公共方法
[](k) 链接
来源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 162 def [](k) @flashes[k.to_s] end
[]=(k, v) 链接
来源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 156 def []=(k, v) k = k.to_s @discard.delete k @flashes[k] = v end
alert() 链接
flash[:alert]
的便捷访问器。
来源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 268 def alert self[:alert] end
alert=(message) 链接
flash[:alert]=
的便捷访问器。
来源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 273 def alert=(message) self[:alert] = message end
clear() 链接
来源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 197 def clear @discard.clear @flashes.clear end
delete(key) 链接
立即删除单个 flash 条目。在当前操作中想要删除消息时使用此方法。另请参见 discard
。
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 182 def delete(key) key = key.to_s @discard.delete key @flashes.delete key self end
discard(k = nil) 链接
标记整个闪存或单个闪存条目在当前操作结束时被丢弃
flash.discard # discard the entire flash at the end of the current action
flash.discard(:warning) # discard only the "warning" entry at the end of the current action
当您希望在当前操作中显示消息,但在下一个操作中不显示时,请使用此方法。另请参见 delete
。
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 253 def discard(k = nil) k = k.to_s if k @discard.merge Array(k || keys) k ? self[k] : self end
each(&block) 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 202 def each(&block) @flashes.each(&block) end
empty?() 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 193 def empty? @flashes.empty? end
initialize_copy(other) 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 148 def initialize_copy(other) if other.now_is_loaded? @now = other.now.dup @now.flash = self end super end
keep(k = nil) 链接
保留整个当前闪存或特定闪存条目以供下一个操作使用
flash.keep # keeps the entire flash
flash.keep(:notice) # keeps only the "notice" entry, the rest of the flash is discarded
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 240 def keep(k = nil) k = k.to_s if k @discard.subtract Array(k || keys) k ? self[k] : self end
key?(name) 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 176 def key?(name) @flashes.key? name.to_s end
keys() 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 172 def keys @flashes.keys end
notice() 链接
flash[:notice]
的便捷访问器。
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 278 def notice self[:notice] end
notice=(message) 链接
flash[:notice]=
的便捷访问器。
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 283 def notice=(message) self[:notice] = message end
now() 链接
设置一个仅对当前操作可用,而对下一个操作不可用的闪存。
flash.now[:message] = "Hello current action"
此方法使你能够将闪存用作应用中的一个中心消息系统。当你需要将一个对象传递给下一个操作时,可以使用标准闪存分配([]=
)。当你需要将一个对象传递给当前操作时,可以使用 now
,而你的对象将在当前操作完成后消失。
通过 now
设置的条目与标准条目以相同的方式访问:flash['my-key']
。
此外,还带来了两个便捷访问器
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!"
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 232 def now @now ||= FlashNow.new(self) end
to_hash() 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 189 def to_hash @flashes.dup end
实例受保护的方法
now_is_loaded?() 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 288 def now_is_loaded? @now end
实例私有方法
stringify_array(array) 链接
来源:显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 293 def stringify_array(array) # :doc: array.map do |item| item.kind_of?(Symbol) ? item.to_s : item end end