Module: Devbootcamp::Auth
- Defined in:
- lib/devbootcamp/auth.rb
Defined Under Namespace
Modules: Helpers Classes: Client
Constant Summary collapse
- Error =
Class.new(StandardError)
Class Attribute Summary collapse
-
.cache ⇒ Object
Returns the value of attribute cache.
Class Method Summary collapse
Class Attribute Details
.cache ⇒ Object
Returns the value of attribute cache.
10 11 12 |
# File 'lib/devbootcamp/auth.rb', line 10 def cache @cache end |
Class Method Details
.get(path, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/devbootcamp/auth.rb', line 12 def get(path, ={}) raise Error, "Devbootcamp::OAuth.token is nil" if Devbootcamp::OAuth.token.nil? cache_for = .delete(:cache_for) make_request = ->(*){ Devbootcamp::OAuth.token.get(path).body } response = if cache && cache_for cache.fetch("Devbootcamp::Auth::#{path}", :expires_in => cache_for, &make_request) else make_request.call end JSON.parse(response) end |