diff options
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/caching.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_controller/mime_responds.rb | 27 | ||||
-rw-r--r-- | actionpack/lib/action_controller/mime_type.rb | 4 |
3 files changed, 11 insertions, 22 deletions
diff --git a/actionpack/lib/action_controller/caching.rb b/actionpack/lib/action_controller/caching.rb index 3c2202e038..ce03a979f8 100644 --- a/actionpack/lib/action_controller/caching.rb +++ b/actionpack/lib/action_controller/caching.rb @@ -251,7 +251,7 @@ module ActionController #:nodoc: private def set_content_type!(controller, extension) - controller.response.content_type = Mime::EXTENSION_LOOKUP[extension].to_s if extension + controller.response.content_type = Mime::Type.lookup_by_extension(extension).to_s if extension end def path_options_for(controller, options) diff --git a/actionpack/lib/action_controller/mime_responds.rb b/actionpack/lib/action_controller/mime_responds.rb index 600877fe4c..a375ac894a 100644 --- a/actionpack/lib/action_controller/mime_responds.rb +++ b/actionpack/lib/action_controller/mime_responds.rb @@ -110,14 +110,11 @@ module ActionController #:nodoc: class Responder #:nodoc: def initialize(controller) - @controller = controller - @request = controller.request - @response = controller.response + @controller = controller + @request = controller.request + @response = controller.response - format = @request.parameters[:format] - @mime_type_priority = format && Mime::EXTENSION_LOOKUP[format] ? - [ Mime::EXTENSION_LOOKUP[format] ] : - @request.accepts + @mime_type_priority = Array(Mime::Type.lookup_by_extension(@request.parameters[:format]) || @request.accepts) @order = [] @responses = {} @@ -128,18 +125,10 @@ module ActionController #:nodoc: @order << mime_type - if block_given? - @responses[mime_type] = Proc.new do - @response.template.template_format = mime_type.to_sym - @response.content_type = mime_type.to_s - block.call - end - else - @responses[mime_type] = Proc.new do - @response.template.template_format = mime_type.to_sym - @response.content_type = mime_type.to_s - @controller.send :render, :action => @controller.action_name - end + @responses[mime_type] = Proc.new do + @response.template.template_format = mime_type.to_sym + @response.content_type = mime_type.to_s + block_given? ? block.call : @controller.send(:render, :action => @controller.action_name) end end diff --git a/actionpack/lib/action_controller/mime_type.rb b/actionpack/lib/action_controller/mime_type.rb index a0e2e70deb..ec9d2eea6d 100644 --- a/actionpack/lib/action_controller/mime_type.rb +++ b/actionpack/lib/action_controller/mime_type.rb @@ -1,7 +1,7 @@ module Mime SET = [] - EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k == "" } - LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k == "" } + EXTENSION_LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? } + LOOKUP = Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? } # Encapsulates the notion of a mime type. Can be used at render time, for example, with: # |