aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/application.rb
blob: 7b50d2622e568c290b4b356b895c6ad27256362b (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
27
28
29
require 'action_controller'

module Rails
  class Application
    def self.load(path, options = {})
      config = options[:config] || 'config.ru'
      config = File.join(path, config)

      if config =~ /\.ru$/
        cfgfile = File.read(config)
        if cfgfile[/^#\\(.*)/]
          opts.parse!($1.split(/\s+/))
        end
        inner_app = eval("::Rack::Builder.new {( " + cfgfile + "\n )}.to_app", nil, config)
      else
        require config
        inner_app = Object.const_get(File.basename(config, '.rb').capitalize)
      end
    end

    def initialize
      @app = ActionController::Dispatcher.new
    end

    def call(env)
      @app.call(env)
    end
  end
end