Module: Mime

Defined in:
lib/action_dispatch/http/mime_type.rb

Defined Under Namespace

Classes: Mimes, NullType, Type

Constant Summary collapse

SET =
Mimes.new
EXTENSION_LOOKUP =
{}
LOOKUP =
Hash.new { |h, k| h[k] = Type.new(k) unless k.blank? }
ALL =

Create Mime::ALL but do not add it to the SET.

Mime::Type.new("*/*", :all, [])

Class Method Summary collapse

Class Method Details

.[](type) ⇒ Object



28
29
30
31
# File 'lib/action_dispatch/http/mime_type.rb', line 28

def [](type)
  return type if type.is_a?(Type)
  Type.lookup_by_extension(type) || NullType.new
end

.fetch(type) ⇒ Object



33
34
35
36
# File 'lib/action_dispatch/http/mime_type.rb', line 33

def fetch(type)
  return type if type.is_a?(Type)
  EXTENSION_LOOKUP.fetch(type.to_s) { |k| yield k }
end