Class: LeanMicrosoftGraph::Authentication::TokenRetriever

Inherits:
Object
  • Object
show all
Defined in:
lib/lean_microsoft_graph/authentication/token_retriever.rb

Instance Method Summary collapse

Constructor Details

#initialize(token_resource) ⇒ TokenRetriever

Returns a new instance of TokenRetriever.



6
7
8
9
# File 'lib/lean_microsoft_graph/authentication/token_retriever.rb', line 6

def initialize(token_resource)
  @token_resource = token_resource
  @token = nil
end

Instance Method Details

#retrieveObject



15
16
17
18
19
# File 'lib/lean_microsoft_graph/authentication/token_retriever.rb', line 15

def retrieve
  return @token if @token && !@token.expired?

  @token = @token_resource.renew
end

#to_procObject



11
12
13
# File 'lib/lean_microsoft_graph/authentication/token_retriever.rb', line 11

def to_proc
  -> { retrieve }
end