Skip to content
Browse files

Do not use ActionController::Base.page_cache_extension in initialize …

…to not load more ActiveSupport than we need
  • Loading branch information...
1 parent 9f0a1ae commit c3c1a1e14859e6716970283caeab0c4c3720862e @drogus drogus committed Sep 3, 2010
Showing with 8 additions and 4 deletions.
  1. +8 −4 actionpack/lib/action_dispatch/middleware/static.rb
View
12 actionpack/lib/action_dispatch/middleware/static.rb
@@ -7,16 +7,13 @@ def initialize(at, root)
@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 @@ def match?(path)
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

0 comments on commit c3c1a1e

Please sign in to comment.
Something went wrong with that request. Please try again.