Module: Voltron::Flash

Defined in:
lib/voltron/flash.rb,
lib/voltron/flash/engine.rb,
lib/voltron/flash/version.rb,
lib/generators/voltron/flash/install_generator.rb,
lib/generators/voltron/flash/install/views_generator.rb,
lib/generators/voltron/flash/install/assets_generator.rb

Defined Under Namespace

Modules: Generators Classes: Engine

Constant Summary collapse

VERSION =
'0.1.6'.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



8
9
10
# File 'lib/voltron/flash.rb', line 8

def self.prepended(base)
  base.send :after_action, :include_flash_later
end

Instance Method Details

#flash!(**flashes) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/voltron/flash.rb', line 22

def flash!(**flashes)
  flashes.symbolize_keys.each do |type,messages|
    stored_flashes[type] ||= []
    stored_flashes[type] += Array.wrap(messages)
  end

  # Set the headers initially. If redirecting, they will be removed as the flash will instead be a part of `flash`
  response.headers[Voltron.config.flash.header] = stored_flashes.to_json
end

#redirect_to(options = {}, response_status = {}) ⇒ Object



17
18
19
20
# File 'lib/voltron/flash.rb', line 17

def redirect_to(options={}, response_status={})
  include_flash_later
  super
end

#render(*args) ⇒ Object



12
13
14
15
# File 'lib/voltron/flash.rb', line 12

def render(*args)
  include_flash_now
  super
end