Sha256: 1fe0c9560f9ad3caa52e73d61043beb8d9f6ad8d24ee03e264a67a6ee98ccdf1

Contents?: true

Size: 567 Bytes

Versions: 1

Compression:

Stored size: 567 Bytes

Contents

require 'active_support/concern'

module Glow
  module Filter
    extend ActiveSupport::Concern
    included do
      after_filter :flash_to_headers
    end

    def flash_to_headers
      return unless flash.any? && request.xhr?
      return if flash[:skip_glow] and flash.delete(:skip_glow)

      type, message = flash.first
      response.headers['X-Message'] = message.to_s.unpack('U*').map{ |i| "&##{i};" }.join
        response.headers['X-Message-Type'] = type.to_s
      flash.discard  # don't want the flash to appear when you reload page
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
glow-0.0.12 lib/glow/filter.rb