lib/koala.rb in koala-1.6.0 vs lib/koala.rb in koala-1.7.0rc1
- old
+ new
@@ -13,41 +13,50 @@
require 'koala/http_service'
# miscellaneous
require 'koala/utils'
require 'koala/version'
+require 'ostruct'
module Koala
# A Ruby client library for the Facebook Platform.
# See http://github.com/arsduo/koala/wiki for a general introduction to Koala
# and the Graph API.
-
+
# Making HTTP requests
class << self
- # Control which HTTP service framework Koala uses.
+ # Control which HTTP service framework Koala uses.
# Primarily used to switch between the mock-request framework used in testing
# and the live framework used in real life (and live testing).
# In theory, you could write your own HTTPService module if you need different functionality,
# but since the switch to {https://github.com/arsduo/koala/wiki/HTTP-Services Faraday} almost all such goals can be accomplished with middleware.
attr_accessor :http_service
+
+ def configure
+ yield config
+ end
+
+ def config
+ @config ||= OpenStruct.new(HTTPService::DEFAULT_SERVERS)
+ end
end
# @private
# For current HTTPServices, switch the service as expected.
# For deprecated services (Typhoeus and Net::HTTP), print a warning and set the default Faraday adapter appropriately.
def self.http_service=(service)
if service.respond_to?(:deprecated_interface)
# if this is a deprecated module, support the old interface
# by changing the default adapter so the right library is used
# we continue to use the single HTTPService module for everything
- service.deprecated_interface
+ service.deprecated_interface
else
# if it's a real http_service, use it
@http_service = service
end
end
- # An convenenient alias to Koala.http_service.make_request.
+ # An convenenient alias to Koala.http_service.make_request.
def self.make_request(path, args, verb, options = {})
http_service.make_request(path, args, verb, options)
end
# we use Faraday as our main service, with mock as the other main one