Class: Procore::Auth::Stores::Dalli
- Inherits:
-
Object
- Object
- Procore::Auth::Stores::Dalli
- Defined in:
- lib/procore/auth/stores/dalli.rb
Instance Attribute Summary collapse
-
#dalli ⇒ Object
readonly
Returns the value of attribute dalli.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #delete ⇒ Object
- #fetch ⇒ Object
-
#initialize(key:, dalli:) ⇒ Dalli
constructor
A new instance of Dalli.
- #save(token) ⇒ Object
Constructor Details
#initialize(key:, dalli:) ⇒ Dalli
Returns a new instance of Dalli.
6 7 8 9 |
# File 'lib/procore/auth/stores/dalli.rb', line 6 def initialize(key:, dalli:) @key = key @dalli = dalli end |
Instance Attribute Details
#dalli ⇒ Object (readonly)
Returns the value of attribute dalli.
5 6 7 |
# File 'lib/procore/auth/stores/dalli.rb', line 5 def dalli @dalli end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/procore/auth/stores/dalli.rb', line 5 def key @key end |
Instance Method Details
#delete ⇒ Object
26 27 28 |
# File 'lib/procore/auth/stores/dalli.rb', line 26 def delete dalli.delete(dalli_key) end |
#fetch ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/procore/auth/stores/dalli.rb', line 15 def fetch return unless dalli.get(dalli_key) token = JSON.parse(dalli.get(dalli_key)) Procore::Auth::Token.new( access_token: token["access_token"], refresh_token: token["refresh_token"], expires_at: token["expires_at"], ) end |
#save(token) ⇒ Object
11 12 13 |
# File 'lib/procore/auth/stores/dalli.rb', line 11 def save(token) dalli.set(dalli_key, token.to_json) end |