Module: Userstream::Connect

Included in:
Userstream
Defined in:
lib/userstream/connect.rb

Defined Under Namespace

Classes: User

Instance Method Summary collapse

Instance Method Details

#get_connection(user, url, method, extras = nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/userstream/connect.rb', line 23

def get_connection(user, url, method, extras = nil)
  options = extras ? extras.merge(:timeout => 0) : {:timeout => 0}
  oauthconfig = {
    :consumer_key     => consumer_token,
    :consumer_secret  => consumer_secret,
    :access_token     => user.access_token,
    :access_token_secret => user.access_secret
  }
  request = EM::HttpRequest.new(url)
  request.use EventMachine::Middleware::OAuth, oauthconfig
  request.send(method, options)       
end