Class: PrepareFlash

Inherits:
Rad::Conveyors::Processor show all
Defined in:
lib/rad/html/processors/prepare_flash.rb

Instance Attribute Summary

Attributes inherited from Rad::Conveyors::Processor

#next_processor

Instance Method Summary collapse

Methods inherited from Rad::Conveyors::Processor

#initialize, inspect

Constructor Details

This class inherits a constructor from Rad::Conveyors::Processor

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rad/html/processors/prepare_flash.rb', line 6

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
    rad[:flash] = Rad::Html::Flash.new workspace.params.format, previous_messages
  end

  next_processor.call

  if rad.include? :flash
    flash = rad[:flash]
    messages = flash.messages_for_next_request
    workspace.request.must_be.present
    workspace.request.session['flash'] = messages.to_json unless messages.empty?
  end
end