Sha256: 2eb8f61d49b96b55b88b5d62e70c7e7d3a9be0153e691cc2316cb607b0050792
Contents?: true
Size: 710 Bytes
Versions: 1
Compression:
Stored size: 710 Bytes
Contents
# encoding: UTF-8 require 'sinatra/base' module Sinatra module ResponseFormat def format_response(data, format) response = case format when 'text/xml' then data.to_xml when 'application/json' then data.to_json when 'text/x-yaml' then data.to_yaml when 'text/csv' then data.to_csv else data.to_json end return response end def format_by_extensions(extension) result = { 'xml' => 'text/xml', 'json' => 'application/json', 'yaml' => 'text/x-yaml', 'csv' => 'text/csv'} return result[extension] end end helpers ResponseFormat end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
clearest-0.0.1a | lib/template/helpers/response_format.rb |