1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00
fb_graph2/lib/fb_graph2.rb
2014-05-03 18:56:42 +09:00

40 lines
No EOL
1.1 KiB
Ruby

require 'active_support/all'
require 'rack/oauth2'
module FbGraph2
VERSION = File.read(File.join(__dir__, '../VERSION')).delete("\n\r")
ROOT_URL = 'https://graph.facebook.com/v2.0'
cattr_accessor :logger, :debugging, :_http_config_
self.logger = Logger.new(STDOUT)
self.logger.progname = 'FbGraph2'
class << self
def debugging?
!!self.debugging
end
def debug!
Rack::OAuth2.debug!
self.debugging = true
end
def http_client(access_token = nil)
_http_client_ = HTTPClient.new(
agent_name: "FbGraph2 (#{VERSION})"
)
_http_client_.request_filter << RequestFilters::Authenticator.new(access_token) if access_token.present?
_http_client_.request_filter << RequestFilters::Debugger.new if self.debugging?
_http_config_.try(:call, _http_client_)
_http_client_
end
def http_config(&block)
Rack::OAuth2.http_config &block unless Rack::OAuth2.http_config
self._http_config_ ||= block
end
end
end
require 'fb_graph2/node'
Dir[File.dirname(__FILE__) + '/fb_graph2/*.rb'].each do |file|
require file
end