Class: TurboFlash::FlashTurbo
- Inherits:
-
ActionDispatch::Flash::FlashNow
- Object
- ActionDispatch::Flash::FlashNow
- TurboFlash::FlashTurbo
- Defined in:
- lib/turbo_flash/flash_turbo.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #[]=(k, v) ⇒ Object
- #clear! ⇒ Object
- #clear_target! ⇒ Object
- #clear_target? ⇒ Boolean
- #cleared? ⇒ Boolean
- #copied_flashes? ⇒ Boolean
- #flashes ⇒ Object
- #from_flash(k, v, options = {}) ⇒ Object
- #from_flashes(other_flashes, options) ⇒ Object
-
#initialize(flash) ⇒ FlashTurbo
constructor
A new instance of FlashTurbo.
- #reset_clear_target! ⇒ Object
- #set_options(options = {}) ⇒ Object
- #unclear! ⇒ Object
Constructor Details
#initialize(flash) ⇒ FlashTurbo
Returns a new instance of FlashTurbo.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/turbo_flash/flash_turbo.rb', line 8 def initialize(flash) super @copied_flashes = false @temp_options = nil @default_render_target = TurboFlash.configuration.target @default_render_options = { action: TurboFlash.configuration.action, partial: TurboFlash.configuration.partial } @locals_key = TurboFlash.configuration.key @locals_value = TurboFlash.configuration.value @options = {} @clear_target = false @cleared = false end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/turbo_flash/flash_turbo.rb', line 6 def @options end |
Instance Method Details
#[]=(k, v) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/turbo_flash/flash_turbo.rb', line 68 def []=(k, v) super @options_for_flash = {} @options_for_flash = @default_render_options.dup @options_for_flash.merge!({ target: @default_render_target }) @options_for_flash[:locals] = { @locals_key => k, @locals_value => v } if @temp_options @options_for_flash.merge!(@temp_options) @temp_options = nil end @options[k.to_s] = @options_for_flash v end |
#clear! ⇒ Object
42 43 44 |
# File 'lib/turbo_flash/flash_turbo.rb', line 42 def clear! @cleared = true end |
#clear_target! ⇒ Object
56 57 58 |
# File 'lib/turbo_flash/flash_turbo.rb', line 56 def clear_target! @clear_target = true end |
#clear_target? ⇒ Boolean
52 53 54 |
# File 'lib/turbo_flash/flash_turbo.rb', line 52 def clear_target? @clear_target end |
#cleared? ⇒ Boolean
34 35 36 |
# File 'lib/turbo_flash/flash_turbo.rb', line 34 def cleared? @cleared end |
#copied_flashes? ⇒ Boolean
21 22 23 |
# File 'lib/turbo_flash/flash_turbo.rb', line 21 def copied_flashes? @copied_flashes end |
#flashes ⇒ Object
64 65 66 |
# File 'lib/turbo_flash/flash_turbo.rb', line 64 def flashes @flash.instance_variable_get(:@flashes) end |
#from_flash(k, v, options = {}) ⇒ Object
46 47 48 49 50 |
# File 'lib/turbo_flash/flash_turbo.rb', line 46 def from_flash(k, v, = {}) ()[k] = v true end |
#from_flashes(other_flashes, options) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/turbo_flash/flash_turbo.rb', line 25 def from_flashes(other_flashes, ) other_flashes.each do |k,v| from_flash(k, v, ) end @copied_flashes = true true end |
#reset_clear_target! ⇒ Object
60 61 62 |
# File 'lib/turbo_flash/flash_turbo.rb', line 60 def reset_clear_target! @clear_target = false end |
#set_options(options = {}) ⇒ Object
86 87 88 89 |
# File 'lib/turbo_flash/flash_turbo.rb', line 86 def ( = {}) @temp_options = self end |
#unclear! ⇒ Object
38 39 40 |
# File 'lib/turbo_flash/flash_turbo.rb', line 38 def unclear! @cleared = false end |