lib/fb_graph/node.rb in fb_graph-0.4.2 vs lib/fb_graph/node.rb in fb_graph-0.5.0

- old
+ new

@@ -18,10 +18,15 @@ def self.fetch(identifier, options = {}) new(identifier).fetch(options) end + def connection(connection, options = {}) + collection = FbGraph::Collection.new(get(options.merge(:connection => connection))) + Connection.new(self, connection, collection) + end + def destroy(options = {}) options[:access_token] ||= self.access_token if self.access_token delete(options) end @@ -56,11 +61,11 @@ private def build_endpoint(params = {}) _endpoint_ = if params[:connection] - File.join(self.endpoint, params.delete(:connection)) + File.join(self.endpoint, params.delete(:connection).to_s) else self.endpoint end params.delete_if do |k, v| @@ -91,18 +96,18 @@ # - error response (JSON) when the identifier contains alphabet (ex. graph.facebook.com/iamnotfound) # - false when the identifier is only integer + underbar (ex. graph.facebook.com/1234567890, graph.facebook.com/12345_67890) # This is an undocumented behaviour, so facebook might chaange it without any announcement. # I've posted this issue on their forum, so hopefully I'll get a document about Graph API error responses. # ref) http://forum.developers.facebook.com/viewtopic.php?pid=228256#p228256 - raise FbGraph::NotFound.new(404, 'Graph API returned false, so probably it means your requested object is not found.') + raise FbGraph::NotFound.new('Graph API returned false, so probably it means your requested object is not found.') else _response_ = JSON.parse(response.body).with_indifferent_access if _response_[:error] case _response_[:error][:type] when 'OAuthAccessTokenException', 'QueryParseException' - raise FbGraph::Unauthorized.new(401, _response_[:error][:message]) + raise FbGraph::Unauthorized.new(_response_[:error][:message]) else - raise FbGraph::Exception.new(400, "#{_response_[:error][:type]} :: #{_response_[:error][:message]}") + raise FbGraph::BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}") end else _response_ end end \ No newline at end of file