shutl_auth 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Shutl
2
2
  module Auth
3
- VERSION = "0.8.4"
3
+ VERSION = "0.8.5"
4
4
  end
5
5
  end
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
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: 4041583274533944112
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: 4041583274533944112
197
+ hash: 1526403474588545504
198
198
  requirements: []
199
199
  rubyforge_project:
200
200
  rubygems_version: 1.8.23