diff options
author | Sven Fuchs <svenfuchs@artweb-design.de> | 2009-02-20 10:50:21 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-02-20 10:50:21 -0600 |
commit | 53fe301a42f9d18b4a8a475e9babf64c621369ae (patch) | |
tree | 32ba2bc4e148c607bbdae56b74c3eb9c6762f86c /actionpack/lib/action_controller | |
parent | 9702636a08e50e9fed9bf76ad620a6a0a109009e (diff) | |
download | rails-53fe301a42f9d18b4a8a475e9babf64c621369ae.tar.gz rails-53fe301a42f9d18b4a8a475e9babf64c621369ae.tar.bz2 rails-53fe301a42f9d18b4a8a475e9babf64c621369ae.zip |
Lazy evaluate middleware arguments [#2028 state:resolved]
Signed-off-by: Joshua Peek <josh@joshpeek.com>
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/middleware_stack.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_controller/middlewares.rb | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/middleware_stack.rb b/actionpack/lib/action_controller/middleware_stack.rb index ee0ae48ac0..b739a6d72d 100644 --- a/actionpack/lib/action_controller/middleware_stack.rb +++ b/actionpack/lib/action_controller/middleware_stack.rb @@ -67,11 +67,17 @@ module ActionController def build(app) if block - klass.new(app, *args, &block) + klass.new(app, *build_args, &block) else - klass.new(app, *args) + klass.new(app, *build_args) end end + + private + + def build_args + Array(args).map { |arg| arg.respond_to?(:call) ? arg.call : arg } + end end def initialize(*args, &block) diff --git a/actionpack/lib/action_controller/middlewares.rb b/actionpack/lib/action_controller/middlewares.rb index fd70eca1b1..371cf6d8f7 100644 --- a/actionpack/lib/action_controller/middlewares.rb +++ b/actionpack/lib/action_controller/middlewares.rb @@ -5,7 +5,7 @@ use "Rack::Lock", :if => lambda { use "ActionController::Failsafe" use lambda { ActionController::Base.session_store }, - ActionController::Base.session_options + lambda { ActionController::Base.session_options } use "ActionController::RewindableInput" use "ActionController::ParamsParser" |