Class: Merb::BootLoader::RackUpApplication

Inherits:
Merb::BootLoader show all
Defined in:
lib/merb-core/bootloader.rb

Class Method Summary collapse

Methods inherited from Merb::BootLoader

after, after_app_loads, before, before_app_loads, default_framework, finished?, inherited, move_klass

Class Method Details

.runObject

Setup the Merb Rack App or read a rackup file located at Merb::Config with the same syntax as the rackup tool that comes with rack. Automatically evals the file in the context of a Rack::Builder.new { } block. Allows for mounting additional apps or middleware.

Returns

nil



1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
# File 'lib/merb-core/bootloader.rb', line 1182

def self.run
  require 'rack'
  if File.exists?(Merb.dir_for(:config) / "rack.rb")
    Merb::Config[:rackup] ||= Merb.dir_for(:config) / "rack.rb"
  end

  if Merb::Config[:rackup]
    rackup_code = File.read(Merb::Config[:rackup])
    Merb::Config[:app] = eval("::Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, Merb::Config[:rackup])
  else
    Merb::Config[:app] = ::Rack::Builder.new {
       if prefix = ::Merb::Config[:path_prefix]
         use Merb::Rack::PathPrefix, prefix
       end
       use Merb::Rack::Static, Merb.dir_for(:public)
       run Merb::Rack::Application.new
     }.to_app
  end
  
  nil
end