Class: Rack::Flash

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/flash.rb,
lib/rack/flash/test.rb

Defined Under Namespace

Classes: FlashHash, SessionUnavailable

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, opts = {}) ⇒ Flash


  • Rack Middleware implementation


130
131
132
133
134
135
136
137
138
# File 'lib/rack/flash.rb', line 130

def initialize(app, opts={})
  if klass = app_class(app, opts)
    klass.class_eval do
      def flash; env['x-rack.flash'] end
    end
  end

  @app, @opts = app, opts
end

Class Method Details

.fake_sessionObject


3
4
5
# File 'lib/rack/flash/test.rb', line 3

def self.fake_session
  @fake_session ||= {}
end

Instance Method Details

#new_call(env) ⇒ Object Also known as: call


8
9
10
11
# File 'lib/rack/flash/test.rb', line 8

def new_call(env)
  env['rack.session'] ||= Rack::Flash.fake_session
  old_call(env)
end