Permalink
Browse files

take 2, works when it's not the immediate super call in the middle ch…

…ain, but requires an explicit option
  • Loading branch information...
1 parent f640720 commit 3c1b93b653105edd135e45990fa8f78e1f98ea8a @knzconnor knzconnor committed Apr 17, 2009
Showing with 5 additions and 7 deletions.
  1. +3 −2 example/base_app.ru
  2. +2 −5 lib/rack/flash.rb
View
@@ -1,5 +1,6 @@
require 'rack/request'
require 'rack/response'
+require 'rack/showexceptions'
require 'rack/session/cookie'
require File.dirname(__FILE__) + '/../lib/rack-flash'
@@ -15,7 +16,7 @@ class Base
res.finish
end
end
-
use Rack::Session::Cookie
-use Rack::Flash
+use Rack::Flash, :flash_app_class => Base
+use Rack::ShowExceptions
run Base.new
View
@@ -101,14 +101,11 @@ class << self; self end.class_eval do
# - Rack Middleware implementation
def initialize(app, opts={})
- if defined?(Sinatra::Base)
- Sinatra::Base.class_eval do
+ if app_class = opts[:flash_app_class] || defined?(Sinatra::Base) && Sinatra::Base
+ app_class.class_eval do
def flash; env['rack-flash'] end
end
- else
- def app.flash; env['rack-flash'];end
end
-
@app, @opts = app, opts
end

0 comments on commit 3c1b93b

Please sign in to comment.