Class: ActionController::Caching::Actions::ActionCachePath

Inherits:
Object
  • Object
show all
Defined in:
lib/action_controller/caching/actions.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(controller, options = {}, infer_extension = true) ⇒ ActionCachePath

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.



148
149
150
151
152
153
154
155
156
157
158
# File 'lib/action_controller/caching/actions.rb', line 148

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)
  add_extension!(path, @extension)
  @path = URI.unescape(path)
end

Instance Attribute Details

#extensionObject (readonly)

Returns the value of attribute extension.



137
138
139
# File 'lib/action_controller/caching/actions.rb', line 137

def extension
  @extension
end

#pathObject (readonly)

Returns the value of attribute path.



137
138
139
# File 'lib/action_controller/caching/actions.rb', line 137

def path
  @path
end

Class Method Details

.path_for(controller, options, infer_extension = true) ⇒ Object



140
141
142
# File 'lib/action_controller/caching/actions.rb', line 140

def path_for(controller, options, infer_extension = true)
  new(controller, options, infer_extension).path
end