aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2010-01-10 23:09:10 -0600
committerJoshua Peek <josh@joshpeek.com>2010-01-10 23:09:10 -0600
commit02bbde4e78f958d5495c19d953aaec58bb8ef998 (patch)
tree3a60347a62e8036a9bee4726e0cc32864b76057d /railties
parent39215860912e4a29def2973b684d0830fc8b9904 (diff)
downloadrails-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 'railties')
-rw-r--r--railties/lib/rails/rack.rb1
-rw-r--r--railties/lib/rails/rack/metal.rb59
-rw-r--r--railties/test/application/metal_test.rb4
-rw-r--r--railties/test/application/middleware_test.rb1
4 files changed, 3 insertions, 62 deletions
diff --git a/railties/lib/rails/rack.rb b/railties/lib/rails/rack.rb
index 9705f65e52..d487bd0542 100644
--- a/railties/lib/rails/rack.rb
+++ b/railties/lib/rails/rack.rb
@@ -2,7 +2,6 @@ module Rails
module Rack
autoload :Debugger, "rails/rack/debugger"
autoload :LogTailer, "rails/rack/log_tailer"
- 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
deleted file mode 100644
index 6c0732f732..0000000000
--- a/railties/lib/rails/rack/metal.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'active_support/ordered_hash'
-require 'active_support/core_ext/class/attribute_accessors'
-require 'active_support/dependencies'
-
-module Rails
- module Rack
- class Metal
- NotFoundResponse = [404, {}, []].freeze
- NotFound = lambda { NotFoundResponse }
-
- cattr_accessor :metal_paths
- self.metal_paths = ["#{Rails.root}/app/metal"]
- cattr_accessor :requested_metals
-
- cattr_accessor :pass_through_on
- self.pass_through_on = 404
-
- def self.metals
- matcher = /#{Regexp.escape('/app/metal/')}(.*)\.rb\Z/
- metal_glob = metal_paths.map{ |base| "#{base}/**/*.rb" }
- all_metals = {}
-
- metal_glob.each do |glob|
- Dir[glob].sort.map do |file|
- file = file.match(matcher)[1]
- all_metals[file.camelize] = file
- end
- end
-
- load_list = requested_metals || all_metals.keys
-
- load_list.map do |requested_metal|
- if metal = all_metals[requested_metal]
- require_dependency metal
- requested_metal.constantize
- end
- end.compact
- end
-
- def initialize(app)
- @app = app
- @pass_through_on = {}
- [*self.class.pass_through_on].each { |status| @pass_through_on[status] = true }
-
- @metals = ActiveSupport::OrderedHash.new
- self.class.metals.each { |app| @metals[app] = true }
- freeze
- end
-
- def call(env)
- @metals.keys.each do |app|
- result = app.call(env)
- return result unless @pass_through_on.include?(result[0].to_i)
- end
- @app.call(env)
- end
- end
- end
-end
diff --git a/railties/test/application/metal_test.rb b/railties/test/application/metal_test.rb
index d3dfb79e8a..225bede117 100644
--- a/railties/test/application/metal_test.rb
+++ b/railties/test/application/metal_test.rb
@@ -37,7 +37,7 @@ module ApplicationTests
app_file 'app/metal/metal_a.rb', <<-RUBY
class MetalA
def self.call(env)
- [404, { "Content-Type" => "text/html"}, ["Metal A"]]
+ [404, { "Content-Type" => "text/html", "X-Cascade" => "pass" }, ["Metal A"]]
end
end
RUBY
@@ -59,7 +59,7 @@ module ApplicationTests
app_file 'app/metal/foo_metal.rb', <<-RUBY
class FooMetal
def self.call(env)
- [404, { "Content-Type" => "text/html"}, ["Not Found"]]
+ [404, { "Content-Type" => "text/html", "X-Cascade" => "pass" }, ["Not Found"]]
end
end
RUBY
diff --git a/railties/test/application/middleware_test.rb b/railties/test/application/middleware_test.rb
index 397968a4e7..8ba3a7bdfc 100644
--- a/railties/test/application/middleware_test.rb
+++ b/railties/test/application/middleware_test.rb
@@ -20,6 +20,7 @@ module ApplicationTests
"ActionDispatch::ShowExceptions",
"ActionDispatch::Callbacks",
"ActionDispatch::Session::CookieStore",
+ "ActionDispatch::Cascade",
"ActionDispatch::ParamsParser",
"Rack::MethodOverride",
"Rack::Head",