aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/rack/metal.rb
blob: 565f95d7c4fa49b0b95e8956320c80e5b3ee5259 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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