Class: Webmachine::Decision::Conneg::MediaTypeList

Inherits:
PriorityList
  • Object
show all
Includes:
Translation
Defined in:
lib/webmachine/decision/conneg.rb

Overview

Like a PriorityList, but for MediaTypes, since they have parameters in addition to q.

Instance Method Summary collapse

Methods included from Translation

#t

Methods inherited from PriorityList

#[], #add, build, #each, #initialize, #priority_of

Constructor Details

This class inherits a constructor from Webmachine::Decision::Conneg::PriorityList

Instance Method Details

#add_header_val(c) ⇒ Object

Overrides PriorityList#add_header_val to insert MediaType items instead of Strings.


228
229
230
231
232
233
234
# File 'lib/webmachine/decision/conneg.rb', line 228

def add_header_val(c)
  mt = MediaType.parse(c)
  q = mt.params.delete('q') || 1.0
  add(q.to_f, mt)
rescue ArgumentError
  raise MalformedRequest, t('invalid_media_type', :type => c)
end