5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/turbo_flash/renderer.rb', line 5
def render(*args)
result = super
if request.format.turbo_stream?
return result if flash.turbo.cleared?
flashed = false
flash_turbo_options = flash.turbo.options
flash.turbo.flashes.each do |key, value|
flash_options = flash_turbo_options[key]
if TurboFlash.configuration.inherit_flashes?
flash.turbo.from_flash(key, value)
flash_options = flash_turbo_options[key]
end
if flash_options.nil?
flash.discard(key)
next
end
result << turbo_stream.send(flash_options.delete(:action), flash_options.delete(:target), **flash_options)
flashed = true
flash.turbo.flash.discard(key)
end
flash.clear
if (!flashed && TurboFlash.configuration.clear_target_unless_flashed?) || flash.turbo.clear_target?
result << turbo_stream.send(:update, TurboFlash.configuration.target) do
""
end
flash.turbo.reset_clear_target!
end
end
result
end
|