Module: Koala::TyphoeusService

Defined in:
lib/koala/http_services.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

this service uses Typhoeus to send requests to the graph



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/koala/http_services.rb', line 58

def self.included(base)
  base.class_eval do
    require 'typhoeus' unless defined?(Typhoeus)
    include Typhoeus

    def self.make_request(path, args, verb, options = {})
      # if the verb isn't get or post, send it as a post argument
      args.merge!({:method => verb}) && verb = "post" if verb != "get" && verb != "post"
      server = options[:rest_api] ? Facebook::REST_SERVER : Facebook::GRAPH_SERVER
      response = self.send(verb, "https://#{server}/#{path}", :params => args)
      Koala::Response.new(response.code, response.body, response.headers_hash)
    end
  end # class_eval
end