Sha256: a4c28ae9ee655842000181b5e23cb270f195cfcd29481c606855286b1177c900

Contents?: true

Size: 502 Bytes

Versions: 2

Compression:

Stored size: 502 Bytes

Contents

module CookieFlash
  def cookie_flash(flash, cookies)
    cookie_flash = (JSON(cookies['flash']) if cookies['flash']) || {} rescue {}

    flash.each do |key, value|
      value = ERB::Util.html_escape(value) unless value.is_a?(Hash) || value.html_safe?
      if cookie_flash[key.to_s].blank?
        cookie_flash[key.to_s] = value.kind_of?(Numeric) ? value.to_s : value
      else
        cookie_flash[key.to_s] << "<br/>#{value}"
      end
    end
    cookie_flash.to_json.gsub("+", "%2B")
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cacheable_flash-0.2.9 lib/cacheable_flash/cookie_flash.rb
cacheable_flash-0.2.8 lib/cacheable_flash/cookie_flash.rb