- #
- A
- C
- D
- E
- I
- K
- N
- S
- T
实例公共方法
[](k) 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 169 def [](k) @flashes[k.to_s] end
[]=(k, v) 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 163 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 280 def alert self[:alert] end
alert=(message) 链接
flash[:alert]= 的便捷访问器。
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 285 def alert=(message) self[:alert] = message end
clear() 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 204 def clear @discard.clear @flashes.clear end
delete(key) 链接
立即删除单个闪存条目。当您想在当前操作中删除消息时使用此方法。另请参阅 discard。
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 189 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 264 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 209 def each(&block) @flashes.each(&block) end
empty?() 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 200 def empty? @flashes.empty? end
initialize_copy(other) 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 155 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 250 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 183 def key?(name) @flashes.key? name.to_s end
keys() 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 179 def keys @flashes.keys end
notice() 链接
flash[:notice] 的便捷访问器。
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 290 def notice self[:notice] end
notice=(message) 链接
flash[:notice]= 的便捷访问器。
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 295 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 241 def now @now ||= FlashNow.new(self) end
to_hash() 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 196 def to_hash @flashes.dup end
实例保护方法
now_is_loaded?() 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 300 def now_is_loaded? @now end
实例私有方法
stringify_array(array) 链接
源: 显示 | 在 GitHub 上
# File actionpack/lib/action_dispatch/middleware/flash.rb, line 305 def stringify_array(array) # :doc: array.map do |item| item.kind_of?(Symbol) ? item.to_s : item end end