Module: FlushingFlash::ActionViewMethods::InstanceMethods

Defined in:
lib/flushing-flash/action_view_methods.rb

Instance Method Summary collapse

Instance Method Details

#flush_flash(target = :default, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/flushing-flash/action_view_methods.rb', line 16

def flush_flash(target=:default, options={})
  msgs = pull_flash(target)
  using_template = options[:using] || nil
  html_safe = options[:html_safe] || false
  
  if msgs.any?
    if using_template
      render partial: using_template, locals: { messages: msgs }
    else
      msgs.collect do |msg|
         :div, class: "flash-message #{msg[:message_type]}" do
          concat (:p, (html_safe ? msg[:content].html_safe : msg[:content]))
        end
      end.join.html_safe
    end
  end
end

#has_flash?(target = :default) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/flushing-flash/action_view_methods.rb', line 12

def has_flash?(target=:default)
  pull_flash(target).any?
end