def respond_to(&block)
wants = {}
def wants.method_missing(type, *args, &handler)
self[type] = handler
end
yield wants
@media_type = accepting_formats.to_a.sort { |a,b| a[1]<=>b[1] }.reverse.select do |format, priority|
wants.keys.include?(format) == true
end.first
if @media_type and @media_type[0]
@media_type = @media_type[0]
headers 'Content-Type' => Rack::MediaType::ACCEPTED_MEDIA_TYPES[@media_type][:return]
wants[@media_type.to_sym].call if wants[@media_type.to_sym]
else
headers 'Content-Type' => nil
status 406
end
end