Module: Roda::RodaPlugins::SinatraHelpers::ClassMethods

Defined in:
lib/roda/plugins/sinatra_helpers.rb

Instance Method Summary collapse

Instance Method Details

#mime_type(type = (return; nil), value = nil) ⇒ Object

If a type and value are given, set the value in Rack’s MIME registry. If only a type is given, lookup the type in Rack’s MIME registry and return it.



481
482
483
484
485
486
487
488
489
# File 'lib/roda/plugins/sinatra_helpers.rb', line 481

def mime_type(type=(return; nil), value = nil)
  return type.to_s if type.to_s.include?('/')
  type = ".#{type}" unless type.to_s[0] == ?.
  if value
    Rack::Mime::MIME_TYPES[type] = value
  else
    Rack::Mime.mime_type(type, nil)
  end
end