1
0
mirror of https://github.com/Eising/kipketer.git synced 2024-05-11 05:55:17 +00:00
Eising-kipketer/webapp/helpers/format_response.rb
Allan Eising e0ff5ca760 First commit
2015-10-27 21:15:36 +01:00

20 lines
425 B
Ruby

class Hastighedstest < Sinatra::Base
def format_response(data, accept)
accept.each do |type|
# return data.to_xml if type.downcase.eql? 'text/xml'
return data.to_json if type.downcase.eql? 'application/json'
return data.to_json
end
end
end
class Hash
def to_xml
map do |k, v|
text = Hash === v ? v.to_xml : v
"<%s>%s</%s>" % [k, text, k]
end.join
end
end