Sha256: d5ebdd5aeacbcca8411811d820f248172dc3df32d766c52ff6a152b25ea7ffe2
Contents?: true
Size: 1011 Bytes
Versions: 3
Compression:
Stored size: 1011 Bytes
Contents
module FbGraph class Query < Node attr_accessor :access_token, :query def initialize(query, access_token = nil) @query = query @access_token = access_token end def fetch(access_token = nil) self.access_token ||= access_token handle_response do RestClient.get build_endpoint end end private ENDPOINT = 'https://api.facebook.com/method/fql.query' def build_endpoint params = stringfy_access_token( :query => self.query, :access_token => self.access_token, :format => :json ) params.delete_if do |k, v| v.blank? end ENDPOINT + "?#{params.to_query}" end def handle_response response = super do yield end case response when Hash if response[:error_code] raise Exception.new(response[:error_code], response[:error_msg]) else response end else response end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fb_graph-1.2.5 | lib/fb_graph/query.rb |
fb_graph-1.2.4 | lib/fb_graph/query.rb |
fb_graph-1.2.3 | lib/fb_graph/query.rb |