diff options
author | José Valim <jose.valim@gmail.com> | 2010-01-17 13:23:14 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-01-17 13:23:38 +0100 |
commit | 020e656447a7cc2ce9cbf83483ab3b31730a565e (patch) | |
tree | ea147ea25a768989e6aaaa57ea026dada4d2f053 /railties/lib/rails | |
parent | 27d9836ad3519d57462b86a4e539c1aa176b6d95 (diff) | |
download | rails-020e656447a7cc2ce9cbf83483ab3b31730a565e.tar.gz rails-020e656447a7cc2ce9cbf83483ab3b31730a565e.tar.bz2 rails-020e656447a7cc2ce9cbf83483ab3b31730a565e.zip |
Move middleware builder back to Rails::Rack::Metal without losing the new behavior.
Diffstat (limited to 'railties/lib/rails')
-rw-r--r-- | railties/lib/rails/configuration.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/rack.rb | 5 | ||||
-rw-r--r-- | railties/lib/rails/rack/metal.rb | 26 |
3 files changed, 30 insertions, 2 deletions
diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index c3e1120fa3..45e2e521ef 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -19,6 +19,7 @@ module Rails middleware.use('ActionDispatch::Cookies') middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options }) middleware.use('ActionDispatch::Flash', :if => lambda { ActionController::Base.session_store }) + middleware.use(lambda { Rails::Rack::Metal.new(Rails.application.config.paths.app.metals.to_a, Rails.application.config.metals) }) middleware.use('ActionDispatch::ParamsParser') middleware.use('::Rack::MethodOverride') middleware.use('::ActionDispatch::Head') diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb index d487bd0542..36945a6b0f 100644 --- a/railties/lib/rails/rack.rb +++ b/railties/lib/rails/rack.rb @@ -1,7 +1,8 @@ module Rails module Rack - autoload :Debugger, "rails/rack/debugger" + autoload :Debugger, "rails/rack/debugger" autoload :LogTailer, "rails/rack/log_tailer" - autoload :Static, "rails/rack/static" + autoload :Metal, "rails/rack/metal" + autoload :Static, "rails/rack/static" end end diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb new file mode 100644 index 0000000000..565f95d7c4 --- /dev/null +++ b/railties/lib/rails/rack/metal.rb @@ -0,0 +1,26 @@ +require 'action_dispatch' + +module Rails + module Rack + class Metal + def initialize(metal_roots, metals=nil) + load_list = metals || Dir["{#{metal_roots.join(",")}}/**/*.rb"] + + @metals = load_list.map { |metal| + metal = File.basename(metal, '.rb') + require_dependency metal + metal.camelize.constantize + }.compact + end + + def new(app) + ActionDispatch::Cascade.new(@metals, app) + end + + def name + ActionDispatch::Cascade.name + end + alias_method :to_s, :name + end + end +end |