Sha256: b730869da3aa03e2ad7d28ee30cb9a5c3740ea06007d8ce2176b4f507c176aa9

Contents?: true

Size: 548 Bytes

Versions: 8

Compression:

Stored size: 548 Bytes

Contents

require 'active_support/concern'

module Glow
  module Filter
    extend ActiveSupport::Concern
    included do
      after_filter :flash_to_headers
    end
    module InstanceMethods
      def flash_to_headers
        return unless flash.any? && request.xhr?
        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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
glow-0.0.9 lib/glow/filter.rb
glow-0.0.8 lib/glow/filter.rb
glow-0.0.7 lib/glow/filter.rb
glow-0.0.6 lib/glow/filter.rb
glow-0.0.5 lib/glow/filter.rb
glow-0.0.4 lib/glow/filter.rb
glow-0.0.3 lib/glow/filter.rb
glow-0.0.2 lib/glow/filter.rb