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 CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "0.4.1"
8
+ s.version = "0.4.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
@@ -28,26 +28,29 @@ module FbGraph
28
28
  protected
29
29
 
30
30
  def get(params = {})
31
- _endpoint_ = build_endpoint(params.merge!(:method => :get))
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
- _endpoint_ = build_endpoint(params.merge!(:method => :post))
39
+ _params_ = stringfy_access_token(params)
40
+ _endpoint_ = build_endpoint(_params_.merge!(:method => :post))
39
41
  handle_response do
40
- RestClient.post(_endpoint_, params)
42
+ RestClient.post(_endpoint_, _params_)
41
43
  end
42
44
  end
43
45
 
44
46
  def delete(params = {})
45
- _endpoint_ = build_endpoint(params.merge!(:method => :delete))
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_, params.merge!(:method => :delete))
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
@@ -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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 1
9
- version: 0.4.1
8
+ - 2
9
+ version: 0.4.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - nov matake