Module: Koala::TyphoeusService

Defined in:
lib/http_services.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object

this service uses Typhoeus to send requests to the graph



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/http_services.rb', line 45

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

    def self.make_request(path, args, verb, graph = true)
      # 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"
      self.send(verb, "https://#{graph ? Facebook::GRAPH_SERVER : Facebook::REST_SERVER}/#{path}", :params => args).body
    end
  end      
end