fb_graph 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/fb_graph.gemspec +1 -1
- data/lib/fb_graph/node.rb +17 -10
- data/spec/fb_graph/page_spec.rb +0 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/fb_graph.gemspec
CHANGED
data/lib/fb_graph/node.rb
CHANGED
@@ -28,26 +28,29 @@ module FbGraph
|
|
28
28
|
protected
|
29
29
|
|
30
30
|
def get(params = {})
|
31
|
-
|
31
|
+
_params_ = stringfy_access_token(params)
|
32
|
+
_endpoint_ = build_endpoint(_params_.merge!(:method => :get))
|
32
33
|
handle_response do
|
33
34
|
RestClient.get(_endpoint_)
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
38
|
def post(params = {})
|
38
|
-
|
39
|
+
_params_ = stringfy_access_token(params)
|
40
|
+
_endpoint_ = build_endpoint(_params_.merge!(:method => :post))
|
39
41
|
handle_response do
|
40
|
-
RestClient.post(_endpoint_,
|
42
|
+
RestClient.post(_endpoint_, _params_)
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
44
46
|
def delete(params = {})
|
45
|
-
|
47
|
+
_params_ = stringfy_access_token(params)
|
48
|
+
_endpoint_ = build_endpoint(_params_.merge!(:method => :delete))
|
46
49
|
handle_response do
|
47
50
|
# NOTE:
|
48
51
|
# DELETE method didn't work for some reason.
|
49
52
|
# Use POST with "method=delete" for now.
|
50
|
-
RestClient.post(_endpoint_,
|
53
|
+
RestClient.post(_endpoint_, _params_.merge!(:method => :delete))
|
51
54
|
end
|
52
55
|
end
|
53
56
|
|
@@ -60,11 +63,6 @@ module FbGraph
|
|
60
63
|
self.endpoint
|
61
64
|
end
|
62
65
|
|
63
|
-
params[:access_token] ||= self.access_token
|
64
|
-
if params[:access_token].is_a?(OAuth2::AccessToken)
|
65
|
-
params[:access_token] = params[:access_token].token
|
66
|
-
end
|
67
|
-
|
68
66
|
params.delete_if do |k, v|
|
69
67
|
v.blank?
|
70
68
|
end
|
@@ -74,6 +72,15 @@ module FbGraph
|
|
74
72
|
_endpoint_
|
75
73
|
end
|
76
74
|
|
75
|
+
def stringfy_access_token(params)
|
76
|
+
_params_ = params.dup
|
77
|
+
_params_[:access_token] ||= self.access_token
|
78
|
+
if access_token.is_a?(OAuth2::AccessToken)
|
79
|
+
_params_[:access_token] = _params_[:access_token].token
|
80
|
+
end
|
81
|
+
_params_
|
82
|
+
end
|
83
|
+
|
77
84
|
def handle_response
|
78
85
|
response = yield
|
79
86
|
case response.body
|
data/spec/fb_graph/page_spec.rb
CHANGED
@@ -12,8 +12,4 @@ describe FbGraph::Page, '.fetch' do
|
|
12
12
|
page.name.should == 'Facebook Platform'
|
13
13
|
page.category.should == 'Technology'
|
14
14
|
end
|
15
|
-
|
16
|
-
it 'should not require access_token' do
|
17
|
-
FbGraph::Page.fetch('platform', :access_token => 'access_token').should == FbGraph::Page.fetch('platform')
|
18
|
-
end
|
19
15
|
end
|