diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 23:25:57 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-04 00:07:38 +0200 |
commit | c3c1a1e14859e6716970283caeab0c4c3720862e (patch) | |
tree | c046d1285d078649db6833fa1b73a6c23f7f16ea /actionpack | |
parent | 9f0a1ae14e2a9306605d7b572612ccf36fa8b2da (diff) | |
download | rails-c3c1a1e14859e6716970283caeab0c4c3720862e.tar.gz rails-c3c1a1e14859e6716970283caeab0c4c3720862e.tar.bz2 rails-c3c1a1e14859e6716970283caeab0c4c3720862e.zip |
Do not use ActionController::Base.page_cache_extension in initialize to not load more ActiveSupport than we need
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_dispatch/middleware/static.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index e7e335df49..581cadbeb4 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -7,16 +7,13 @@ module ActionDispatch @compiled_at = Regexp.compile(/^#{Regexp.escape(at)}/) unless @at.blank? @compiled_root = Regexp.compile(/^#{Regexp.escape(root)}/) @file_server = ::Rack::File.new(root) - - ext = ::ActionController::Base.page_cache_extension - @ext = "{,#{ext},/index#{ext}}" end def match?(path) path = path.dup if @compiled_at.blank? || path.sub!(@compiled_at, '') full_path = File.join(@root, ::Rack::Utils.unescape(path)) - paths = "#{full_path}#{@ext}" + paths = "#{full_path}#{ext}" matches = Dir[paths] match = matches.detect { |m| File.file?(m) } @@ -30,6 +27,13 @@ module ActionDispatch def call(env) @file_server.call(env) end + + def ext + @ext ||= begin + ext = ::ActionController::Base.page_cache_extension + "{,#{ext},/index#{ext}}" + end + end end class Static |