Skip to content

Commit

Permalink
take 2, works when it's not the immediate super call in the middle ch…
Browse files Browse the repository at this point in the history
…ain, but requires an explicit option
  • Loading branch information
knzconnor committed Apr 17, 2009
1 parent f640720 commit 3c1b93b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 3 additions & 2 deletions example/base_app.ru
@@ -1,5 +1,6 @@
require 'rack/request'
require 'rack/response'
require 'rack/showexceptions'
require 'rack/session/cookie'
require File.dirname(__FILE__) + '/../lib/rack-flash'

Expand All @@ -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
7 changes: 2 additions & 5 deletions lib/rack/flash.rb
Expand Up @@ -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

Expand Down

0 comments on commit 3c1b93b

Please sign in to comment.