diff options
Diffstat (limited to 'railties/lib/rails/rack/metal.rb')
-rw-r--r-- | railties/lib/rails/rack/metal.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/railties/lib/rails/rack/metal.rb b/railties/lib/rails/rack/metal.rb new file mode 100644 index 0000000000..1df31a1594 --- /dev/null +++ b/railties/lib/rails/rack/metal.rb @@ -0,0 +1,27 @@ +require 'rails/rack/cascade' + +module Rails + module Rack + module Metal + NotFoundResponse = [404, {}, []].freeze + NotFound = lambda { NotFoundResponse } + + class << self + def new(app) + Cascade.new(builtins + [app]) + end + + def builtins + base = "#{Rails.root}/app/metal" + matcher = /\A#{Regexp.escape(base)}\/(.*)\.rb\Z/ + + Dir["#{base}/**/*.rb"].sort.map do |file| + file.sub!(matcher, '\1') + require file + file.classify.constantize + end + end + end + end + end +end |