Permalink
Browse files

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

  • Loading branch information...
1 parent 29158d4 commit 9731c5213b9f1a46c478da862b43cbf708da40da Carlhuda committed Mar 3, 2010
Showing with 11 additions and 11 deletions.
  1. +0 −4 railties/lib/rails/application.rb
  2. +10 −6 railties/lib/rails/configuration.rb
  3. +1 −1 railties/lib/rails/engine.rb
View
4 railties/lib/rails/application.rb
@@ -55,10 +55,6 @@ def railties
@railties ||= Railties.new(config)
end
- def metal_loader
- @metal_loader ||= MetalLoader.new
- end
-
def routes_reloader
@routes_reloader ||= RoutesReloader.new
end
View
16 railties/lib/rails/configuration.rb
@@ -50,6 +50,10 @@ def respond_to?(name)
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 @@ def options
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
2 railties/lib/rails/engine.rb
@@ -41,7 +41,7 @@ def find_root_with_flag(flag, default=nil)
end
end
- delegate :middleware, :paths, :root, :to => :config
+ delegate :middleware, :paths, :metal_loader, :root, :to => :config
def load_tasks
super

0 comments on commit 9731c52

Please sign in to comment.