Method: Rack::MediaType.params

Defined in:
lib/rack/media_type.rb

.params(content_type) ⇒ Object

The media type parameters provided in CONTENT_TYPE as a Hash, or an empty Hash if no CONTENT_TYPE or media-type parameters were provided. e.g., when the CONTENT_TYPE is “text/plain;charset=utf-8”, this method responds with the following Hash:

{ 'charset' => 'utf-8' }

24
25
26
27
28
29
# File 'lib/rack/media_type.rb', line 24

def params(content_type)
  return {} if content_type.nil?
  Hash[*content_type.split(SPLIT_PATTERN)[1..-1].
    collect { |s| s.split('=', 2) }.
    map { |k,v| [k.downcase, strip_doublequotes(v)] }.flatten]
end