Sha256: 5f770dd5a8bbaa3ea4d3be9d4de509bac45789eaf3c4d80578802f53a8507b94

Contents?: true

Size: 392 Bytes

Versions: 6

Compression:

Stored size: 392 Bytes

Contents

module Alf
  class Renderer

    def self.supported_media_types
      each.map{|(_,_,r)| r.mime_type}.compact.sort
    end

    def self.from_http_accept(accept)
      media_type = Rack::Accept::MediaType.new(accept)
      if best = media_type.best_of(supported_media_types)
        each.find{|(name,_,r)| r.mime_type == best }.last
      end
    end

  end # class Renderer
end # module Alf

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
alf-rest-0.17.1 lib/alf/rest/alf-ext/renderer.rb
alf-rest-0.16.3 lib/alf/rest/alf-ext/renderer.rb
alf-rest-0.16.2 lib/alf/rest/alf-ext/renderer.rb
alf-rest-0.16.1 lib/alf/rest/alf-ext/renderer.rb
alf-rest-0.16.0 lib/alf/rest/alf-ext/renderer.rb
alf-rest-0.14.0 lib/alf/rest/alf-ext/renderer.rb