shutl_auth 0.8.4 → 0.8.5
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/lib/shutl/auth/authenticated_request.rb +17 -17
- data/lib/shutl/auth/version.rb +1 -1
- metadata +3 -3
@@ -16,15 +16,29 @@ module Shutl
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def self.cache
|
20
|
+
@cache ||= build_cache
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def self.build_cache
|
26
|
+
if Kernel.const_defined?(:Rails)
|
27
|
+
::Rails.cache
|
28
|
+
else
|
29
|
+
Cache.new
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
19
33
|
module AuthenticatedRequest
|
20
34
|
def self.included base
|
21
35
|
|
22
36
|
end
|
23
37
|
|
24
38
|
def request_access_token
|
39
|
+
return read_token if read_token
|
25
40
|
Shutl::Auth.logger.debug "request_access_token: cached? #{!!read_token}"
|
26
41
|
|
27
|
-
Shutl::Auth.logger.debug "requesting new access token"
|
28
42
|
Shutl::Auth.access_token!
|
29
43
|
end
|
30
44
|
|
@@ -45,25 +59,11 @@ module Shutl
|
|
45
59
|
end
|
46
60
|
|
47
61
|
def read_token
|
48
|
-
cache.read(:access_token)
|
62
|
+
Shutl::Auth.cache.read(:access_token)
|
49
63
|
end
|
50
64
|
|
51
65
|
def set_token(token)
|
52
|
-
cache.write(:access_token, token)
|
53
|
-
end
|
54
|
-
|
55
|
-
def cache
|
56
|
-
@cache ||= build_cache
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def build_cache
|
62
|
-
if Kernel.const_defined?(:Rails)
|
63
|
-
::Rails.cache
|
64
|
-
else
|
65
|
-
Cache.new
|
66
|
-
end
|
66
|
+
Shutl::Auth.cache.write(:access_token, token)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
data/lib/shutl/auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shutl_auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -185,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
segments:
|
187
187
|
- 0
|
188
|
-
hash:
|
188
|
+
hash: 1526403474588545504
|
189
189
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
190
|
none: false
|
191
191
|
requirements:
|
@@ -194,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
version: '0'
|
195
195
|
segments:
|
196
196
|
- 0
|
197
|
-
hash:
|
197
|
+
hash: 1526403474588545504
|
198
198
|
requirements: []
|
199
199
|
rubyforge_project:
|
200
200
|
rubygems_version: 1.8.23
|