Module: FlashMessages::Display

Defined in:
lib/jquery/flash_messages.rb

Constant Summary collapse

FLASH_NOTICE_KEYS =

end

[:error, :warning, :notice, :success]

Instance Method Summary collapse

Instance Method Details

#flash_messagesObject



27
28
29
30
31
32
33
34
35
# File 'lib/jquery/flash_messages.rb', line 27

def flash_messages
  return unless messages = flash.keys.select { |k| FLASH_NOTICE_KEYS.include?(k) }
  formatted_messages = messages.map do |type|
    (:div, nil, :class => type.to_s + " ui-corner-all") do
      message_for_item(flash[type], flash["#{type}_item".to_sym])
    end
  end
  formatted_messages.join
end

#message_for_item(message, item = nil) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/jquery/flash_messages.rb', line 37

def message_for_item(message, item = nil)
  if item.is_a?(Array)
    (:div, nil, :class => :icon) + message % link_to(*item)
  else
    (:div, nil, :class => :icon) + message % item
  end
end