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.



496
497
498
499
500
501
502
503
504
# File 'lib/roda/plugins/sinatra_helpers.rb', line 496

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