1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Don't rely on Rails.application global state in Config

This commit is contained in:
Carlhuda 2010-03-03 15:23:39 -08:00
parent 29158d4158
commit 9731c5213b
3 changed files with 11 additions and 11 deletions

View file

@ -55,10 +55,6 @@ module Rails
@railties ||= Railties.new(config)
end
def metal_loader
@metal_loader ||= MetalLoader.new
end
def routes_reloader
@routes_reloader ||= RoutesReloader.new
end

View file

@ -50,6 +50,10 @@ module Rails
super || name.to_s =~ config_key_regexp
end
def metal_loader
@metal_loader ||= Rails::Application::MetalLoader.new
end
private
def method_missing(name, *args, &blk)
@ -75,17 +79,17 @@ module Rails
def default_middleware
require 'action_dispatch'
ActionDispatch::MiddlewareStack.new.tap do |middleware|
middleware.use('::ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { Rails.application.config.serve_static_assets })
middleware.use('::Rack::Lock', :if => lambda { !Rails.application.config.allow_concurrency })
middleware.use('::ActionDispatch::Static', lambda { Rails.public_path }, :if => lambda { serve_static_assets })
middleware.use('::Rack::Lock', :if => lambda { !allow_concurrency })
middleware.use('::Rack::Runtime')
middleware.use('::Rails::Rack::Logger')
middleware.use('::ActionDispatch::ShowExceptions', lambda { Rails.application.config.consider_all_requests_local })
middleware.use('::Rack::Sendfile', lambda { Rails.application.config.action_dispatch.x_sendfile_header })
middleware.use('::ActionDispatch::Callbacks', lambda { !Rails.application.config.cache_classes })
middleware.use('::ActionDispatch::ShowExceptions', lambda { consider_all_requests_local })
middleware.use('::Rack::Sendfile', lambda { action_dispatch.x_sendfile_header })
middleware.use('::ActionDispatch::Callbacks', lambda { !cache_classes })
middleware.use('::ActionDispatch::Cookies')
middleware.use(lambda { ActionController::Base.session_store }, lambda { ActionController::Base.session_options })
middleware.use('::ActionDispatch::Flash', :if => lambda { ActionController::Base.session_store })
middleware.use(lambda { Rails.application.metal_loader.build_middleware(Rails.application.config.metals) }, :if => lambda { Rails.application.metal_loader.metals.any? })
middleware.use(lambda { metal_loader.build_middleware(metals) }, :if => lambda { metal_loader.metals.any? })
middleware.use('ActionDispatch::ParamsParser')
middleware.use('::Rack::MethodOverride')
middleware.use('::ActionDispatch::Head')

View file

@ -41,7 +41,7 @@ module Rails
end
end
delegate :middleware, :paths, :root, :to => :config
delegate :middleware, :paths, :metal_loader, :root, :to => :config
def load_tasks
super