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

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

Instance Method Summary collapse

Instance Method Details

#mime_type(type = nil || (return), 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.



511
512
513
514
515
516
517
518
519
# File 'lib/roda/plugins/sinatra_helpers.rb', line 511

def mime_type(type=nil || (return), 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