Class: Procore::Auth::Stores::Redis
- Inherits:
-
Object
- Object
- Procore::Auth::Stores::Redis
- Defined in:
- lib/procore/auth/stores/redis.rb
Instance Attribute Summary collapse
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#redis ⇒ Object
readonly
Returns the value of attribute redis.
Instance Method Summary collapse
- #delete ⇒ Object
- #fetch ⇒ Object
-
#initialize(key:, redis:) ⇒ Redis
constructor
A new instance of Redis.
- #save(token) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key:, redis:) ⇒ Redis
Returns a new instance of Redis.
6 7 8 9 |
# File 'lib/procore/auth/stores/redis.rb', line 6 def initialize(key:, redis:) @key = key @redis = redis end |
Instance Attribute Details
#key ⇒ Object (readonly)
Returns the value of attribute key.
5 6 7 |
# File 'lib/procore/auth/stores/redis.rb', line 5 def key @key end |
#redis ⇒ Object (readonly)
Returns the value of attribute redis.
5 6 7 |
# File 'lib/procore/auth/stores/redis.rb', line 5 def redis @redis end |
Instance Method Details
#delete ⇒ Object
26 27 28 |
# File 'lib/procore/auth/stores/redis.rb', line 26 def delete redis.del(redis_key) end |
#fetch ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/procore/auth/stores/redis.rb', line 15 def fetch return unless redis.exists(redis_key) token = JSON.parse(redis.get(redis_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/redis.rb', line 11 def save(token) redis.set(redis_key, token.to_json) end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/procore/auth/stores/redis.rb', line 30 def to_s "Redis, Key: #{redis_key}" end |