Created
June 4, 2009 13:55
-
-
Save r38y/123623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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