Skip to content

Instantly share code, notes, and snippets.

@r38y
Created June 4, 2009 13:55
Show Gist options
  • Save r38y/123623 to your computer and use it in GitHub Desktop.
Save r38y/123623 to your computer and use it in GitHub Desktop.
module Grackle
module Handlers
# Decodes JSON Twitter API responses but doesn't turn them into OpenStructs
class JSON2Handler
def decode_response(res)
JSON.parse(res)
end
end
end
class Client
VALID_FORMATS << :json2
protected
def call_with_format(format,params={})
real_format = [:json, :json2].include?(format) ? :json : format
id = params.delete(:id)
request << "/#{id}" if id
request << ".#{real_format}"
res = send_request(params)
process_response(format,res)
ensure
clear
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment