nakajima (owner)

Fork Of

Forks

Revisions

gist: 108480 Download_button fork
public
Description:
aesthetics
Public Clone URL: git://gist.github.com/108480.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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