Permalink
Browse files

Refactor iteration over Mime types

  • Loading branch information...
1 parent 308df6c commit e692679e92cdf4f653b8249d112961a090632ce4 @cch1 committed Oct 12, 2010
Showing with 7 additions and 11 deletions.
  1. +7 −11 actionpack/lib/action_controller/caching/actions.rb
@@ -95,18 +95,14 @@ def filter(controller, action)
def before(controller)
cache_path = ActionCachePath.new(controller, path_options_for(controller, @options.slice(:cache_path)))
responder = MimeResponds::Responder.new(controller)
- # To which types can we respond from cache? Best Answer: query cache store. Cheap Answer: use static config.
- # OPTIMIZE: Query cache store to determine which types can be responded to from cache.
types = @options[:store_options][:cache_types] || [:any]
- types.each do |type|
- responder.send(type) do
- path = cache_path.path(controller.response.template.template_format.to_sym)
- if cache = controller.read_fragment(path, @options[:store_options])
- controller.rendered_action_cache = true
- options = { :text => cache }
- options.merge!(:layout => true) if cache_layout?
- controller.__send__(:render, options)
- end
+ responder.any(*types) do
+ path = cache_path.path(controller.response.template.template_format.to_sym)
+ if cache = controller.read_fragment(path, @options[:store_options])
+ controller.rendered_action_cache = true
+ options = { :text => cache }
+ options.merge!(:layout => true) if cache_layout?
+ controller.__send__(:render, options)
end
end
responder.respond

0 comments on commit e692679

Please sign in to comment.