lib/inout.rb
# Determines the format the client is expecting
#
Determines the format the client is expecting
Determines the format the client is expecting
def determine_out_format (options={})
    f = options[:format] || params[:format] || request.env['_FORMAT']
    return FORMATS[:xml] if f == 'xml'
    return FORMATS[:json] if f == 'json'
    return FORMATS[:js] if f == 'js'
    return FORMATS[:yaml] if f == 'yaml'
    return FORMATS[:atom] if f == 'atom'
    accept = request.env['HTTP_ACCEPT'] || ''
    return FORMATS[:html] if accept.index('text/html')
    return FORMATS[:yaml] if accept.index('yaml')
    return FORMATS[:json] if accept.index('json')
    return FORMATS[:js] if accept.index('js')
    return FORMATS[:atom] if accept.index('atom')
    FORMATS[:xml]
  end
def determine_out_format ( options = { } ) f = options [ :format ] || params [ :format ] || request . env [ '_FORMAT' ] return FORMATS [ :xml ] if f == 'xml' return FORMATS [ :json ] if f == 'json' return FORMATS [ :js ] if f == 'js' return FORMATS [ :yaml ] if f == 'yaml' return FORMATS [ :atom ] if f == 'atom' accept = request . env [ 'HTTP_ACCEPT' ] || '' return FORMATS [ :html ] if accept . index ( 'text/html' ) return FORMATS [ :yaml ] if accept . index ( 'yaml' ) return FORMATS [ :json ] if accept . index ( 'json' ) return FORMATS [ :js ] if accept . index ( 'js' ) return FORMATS [ :atom ] if accept . index ( 'atom' ) FORMATS [ :xml ] end
Determines the format the client is expecting
Determines the format the client is expecting
options
<not_specific>