diff options
author | Joshua Peek <josh@joshpeek.com> | 2010-01-10 23:09:10 -0600 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2010-01-10 23:09:10 -0600 |
commit | 02bbde4e78f958d5495c19d953aaec58bb8ef998 (patch) | |
tree | 3a60347a62e8036a9bee4726e0cc32864b76057d /actionpack/lib/action_controller | |
parent | 39215860912e4a29def2973b684d0830fc8b9904 (diff) | |
download | rails-02bbde4e78f958d5495c19d953aaec58bb8ef998.tar.gz rails-02bbde4e78f958d5495c19d953aaec58bb8ef998.tar.bz2 rails-02bbde4e78f958d5495c19d953aaec58bb8ef998.zip |
Cleanup junk metal and revise API
API Change: Returning a "X-Cascade: pass" header triggers the cascade
instead of a 404 response.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/railtie.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 6b94c32b2a..42257f9400 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -37,11 +37,33 @@ module ActionController ActionController::Base.view_paths = view_path if ActionController::Base.view_paths.blank? end + class MetalMiddlewareBuilder + def initialize(metals) + @metals = metals + end + + def new(app) + ActionDispatch::Cascade.new(@metals, app) + end + + def name + ActionDispatch::Cascade.name + end + alias_method :to_s, :name + end + initializer "action_controller.initialize_metal" do |app| - Rails::Rack::Metal.requested_metals = app.config.metals + metal_root = "#{Rails.root}/app/metal" + load_list = app.config.metals || Dir["#{metal_root}/**/*.rb"] + + metals = load_list.map { |metal| + metal = File.basename(metal.gsub("#{metal_root}/", ''), '.rb') + require_dependency metal + metal.camelize.constantize + }.compact - app.config.middleware.insert_before(:"ActionDispatch::ParamsParser", - Rails::Rack::Metal, :if => Rails::Rack::Metal.metals.any?) + middleware = MetalMiddlewareBuilder.new(metals) + app.config.middleware.insert_before(:"ActionDispatch::ParamsParser", middleware) end # # Prepare dispatcher callbacks and run 'prepare' callbacks |