From 2dbb73bdda3b81947fd112486ac4285fb1a6e3a9 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 28 Feb 2011 17:54:00 -0800 Subject: compute ext in initialize, and use an attr_reader --- actionpack/lib/action_dispatch/middleware/static.rb | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/middleware/static.rb b/actionpack/lib/action_dispatch/middleware/static.rb index 913b899e20..40c85d420a 100644 --- a/actionpack/lib/action_dispatch/middleware/static.rb +++ b/actionpack/lib/action_dispatch/middleware/static.rb @@ -2,11 +2,16 @@ require 'rack/utils' module ActionDispatch class FileHandler + attr_reader :ext + def initialize(at, root) @at, @root = at.chomp('/'), root.chomp('/') @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) @@ -27,13 +32,6 @@ 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 -- cgit v1.2.3