Skip to content

Instantly share code, notes, and snippets.

@nakajima
Forked from pauldix/gist:108444
Created May 7, 2009 23:50
Show Gist options
  • Select an option

  • Save nakajima/108480 to your computer and use it in GitHub Desktop.

Select an option

Save nakajima/108480 to your computer and use it in GitHub Desktop.
aesthetics
# Currently it looks like this:
class Twitter
include Typhoeus
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
:on_failure => lambda {|response| puts "error code: #{response.code}"},
:base_uri => "http://search.twitter.com"
define_remote_method :search, :path => '/search.json'
define_remote_method :trends, :path => '/trends/:time_frame.json'
end
# I want it to look like this. Fork coming soon.
class Twitter
Typhoeus "http://search.twitter.com" do
success { |response| JSON.parse(response.body) }
failure { |response| puts "error code: #{response.code}" }
expires_in 60 # instead of :cache_responses
method :search, :path => '/search.json'
method :trends, :path => '/trends/:time_frame.json'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment