From 7ef6a27f89ee2cccc3a8f73123d2a7173c85f52f Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 3 Jul 2012 17:51:27 -0700 Subject: add Mime.fetch so we can have default mime types --- actionpack/lib/action_dispatch/http/mime_type.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionpack/lib/action_dispatch/http') diff --git a/actionpack/lib/action_dispatch/http/mime_type.rb b/actionpack/lib/action_dispatch/http/mime_type.rb index ee1913dbf9..83cd3d1ca8 100644 --- a/actionpack/lib/action_dispatch/http/mime_type.rb +++ b/actionpack/lib/action_dispatch/http/mime_type.rb @@ -29,6 +29,11 @@ module Mime Type.lookup_by_extension(type.to_s) end + def self.fetch(type) + return type if type.is_a?(Type) + EXTENSION_LOOKUP.fetch(type.to_s) { |k| yield k } + end + # Encapsulates the notion of a mime type. Can be used at render time, for example, with: # # class PostsController < ActionController::Base -- cgit v1.2.3