Class: AcceptableApi::Accepts

Inherits:
Object
  • Object
show all
Defined in:
lib/acceptable_api/accepts.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Accepts

Returns a new instance of Accepts.



6
7
8
# File 'lib/acceptable_api/accepts.rb', line 6

def initialize env
  self.request = Rack::Accept::Request.new env
end

Instance Method Details

#order(mime_types) ⇒ Object



10
11
12
13
14
# File 'lib/acceptable_api/accepts.rb', line 10

def order mime_types
  ordered = request.media_type.sort_with_qvalues mime_types, false
  ordered.map! { |q, mt| mt }
  ordered
end