aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/railtie.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/railtie.rb')
-rw-r--r--actionpack/lib/action_controller/railtie.rb28
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