Class: CacheableFlash::Middleware
- Inherits:
-
Object
- Object
- CacheableFlash::Middleware
- Includes:
- CookieFlash
- Defined in:
- lib/cacheable_flash/middleware.rb
Constant Summary collapse
- FLASH_HASH_KEY =
"action_dispatch.request.flash_hash".freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Methods included from CookieFlash
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
8 9 10 |
# File 'lib/cacheable_flash/middleware.rb', line 8 def initialize(app) @app = app end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/cacheable_flash/middleware.rb', line 12 def call(env) status, headers, body = @app.call(env) env_flash = env[FLASH_HASH_KEY] if env_flash domain = CacheableFlash::Config.config[:domain] = Rack::Request.new(env). Rack::Utils.(headers, "flash", :value => (env_flash, ), :path => "/", :domain => domain) end [status, headers, body] end |