class ActionController::Caching::Actions::ActionCachePath
Attributes
extension[R]
path[R]
Public Class Methods
new(controller, options = {}, infer_extension = true)
click to toggle source
If infer_extension
is true
, the cache path extension is looked up from the request's path and 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.
# File lib/action_controller/caching/actions.rb, line 212 def initialize(controller, options = {}, infer_extension = true) if infer_extension if controller.params.key?(:format) @extension = controller.params[:format] elsif !controller.request.format.html? @extension = controller.request.format.to_sym else @extension = nil end options.reverse_merge!(format: @extension) if options.is_a?(Hash) end path = controller.url_for(options).split("://", 2).last @path = normalize!(path) end
Private Instance Methods
normalize!(path)
click to toggle source
# File lib/action_controller/caching/actions.rb, line 230 def normalize!(path) ext = URI::DEFAULT_PARSER.escape(extension.to_s) if extension path << "index" if path[-1] == ?/ path << ".#{ext}" if extension && !path.split("?", 2).first.end_with?(".#{ext}") URI::DEFAULT_PARSER.unescape(path) end