diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-03-12 15:31:24 +0000 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-03-12 15:31:24 +0000 |
commit | 53744c543880999a7ad3f1e026875df3283978f1 (patch) | |
tree | 8d01e0c15a384a46db176ad8d5cdd0bd6c9024a8 /actionpack/lib/action_controller/caching/actions.rb | |
parent | 053afbe3bd26d627ee04a0aaa73554b7be422f05 (diff) | |
parent | 47bdf3bf40ec17e1f8ca1c0e3d7f697d0c4cd1bf (diff) | |
download | rails-53744c543880999a7ad3f1e026875df3283978f1.tar.gz rails-53744c543880999a7ad3f1e026875df3283978f1.tar.bz2 rails-53744c543880999a7ad3f1e026875df3283978f1.zip |
Merge commit 'mainstream/master'
Conflicts:
actionpack/lib/action_view/helpers/text_helper.rb
activesupport/lib/active_support/inflector.rb
Diffstat (limited to 'actionpack/lib/action_controller/caching/actions.rb')
-rw-r--r-- | actionpack/lib/action_controller/caching/actions.rb | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/actionpack/lib/action_controller/caching/actions.rb b/actionpack/lib/action_controller/caching/actions.rb index 34e1c3527f..87b5029e57 100644 --- a/actionpack/lib/action_controller/caching/actions.rb +++ b/actionpack/lib/action_controller/caching/actions.rb @@ -129,24 +129,23 @@ module ActionController #:nodoc: attr_reader :path, :extension class << self - def path_for(controller, options, infer_extension=true) + def path_for(controller, options, infer_extension = true) new(controller, options, infer_extension).path end end # When true, infer_extension will look up the cache path extension from the request's path & format. - # This is desirable when reading and writing the cache, but not when expiring the cache - expire_action should expire the same files regardless of the request format. - def initialize(controller, options = {}, infer_extension=true) - if infer_extension and options.is_a? Hash - request_extension = extract_extension(controller.request) - options = options.reverse_merge(:format => request_extension) + # This is desirable when reading and writing the cache, but not when expiring the cache - + # expire_action should expire the same files regardless of the request format. + def initialize(controller, options = {}, infer_extension = true) + if infer_extension + extract_extension(controller.request) + options = options.reverse_merge(:format => @extension) if options.is_a?(Hash) end + path = controller.url_for(options).split('://').last normalize!(path) - if infer_extension - @extension = request_extension - add_extension!(path, @extension) - end + add_extension!(path, @extension) @path = URI.unescape(path) end @@ -162,13 +161,7 @@ module ActionController #:nodoc: def extract_extension(request) # Don't want just what comes after the last '.' to accommodate multi part extensions # such as tar.gz. - extension = request.path[/^[^.]+\.(.+)$/, 1] - - # If there's no extension in the path, check request.format - if extension.nil? - extension = request.cache_format - end - extension + @extension = request.path[/^[^.]+\.(.+)$/, 1] || request.cache_format end end end |