Sha256: e3be2dd02589375b4edf96b4b81efbe97bcc81f8e55a7e25fc1da65e9eace271

Contents?: true

Size: 784 Bytes

Versions: 3

Compression:

Stored size: 784 Bytes

Contents

module Crystal
  module Processors
    class PrepareFlash < Processor

      def call
        workspace.request.must_be.present
        workspace.params.must_be.defined
        
        previous_messages = workspace.request.session.delete 'flash'
        if previous_messages.present?
          previous_messages = JSON.load previous_messages
          crystal[:flash] = Crystal::Flash.new workspace.params.format, previous_messages
        end
        
        next_processor.call
        
        if crystal.include? :flash
          flash = crystal[:flash]
          messages = flash.messages_for_next_request
          workspace.request.must_be.present
          workspace.request.session['flash'] = messages.to_json unless messages.empty?
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
crystal-0.0.13 lib/crystal/html/processors/prepare_flash.rb
crystal-0.0.12 lib/crystal/html/processors/prepare_flash.rb
crystal_ext-0.0.11 lib/crystal/html/processors/prepare_flash.rb