module Devbootcamp::Auth

Constants

Error

Attributes

cache[RW]

Public Class Methods

get(path, options={}) click to toggle source
# File lib/devbootcamp/auth.rb, line 12
def get(path, options={})
  raise Error, "Devbootcamp::OAuth.token is nil" if Devbootcamp::OAuth.token.nil?

  cache_for = options.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