Class: Google::APIClient::RedisStore
- Inherits:
-
Object
- Object
- Google::APIClient::RedisStore
- Defined in:
- lib/google/api_client/auth/storages/redis_store.rb
Constant Summary collapse
- DEFAULT_REDIS_CREDENTIALS_KEY =
"google_api_credentials"
Instance Attribute Summary collapse
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
-
#initialize(redis, key = nil) ⇒ RedisStore
constructor
Initializes the RedisStore object.
-
#load_credentials ⇒ Object
Attempt to read in credentials from redis.
- #redis_credentials_key ⇒ Object
-
#write_credentials(credentials_hash) ⇒ Object
Write the credentials to redis.
Constructor Details
#initialize(redis, key = nil) ⇒ RedisStore
Initializes the RedisStore object.
29 30 31 32 |
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 29 def initialize(redis, key = nil) @redis= redis @redis_credentials_key = key end |
Instance Attribute Details
#redis ⇒ Object
Returns the value of attribute redis.
23 24 25 |
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 23 def redis @redis end |
Instance Method Details
#load_credentials ⇒ Object
Attempt to read in credentials from redis.
36 37 38 39 |
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 36 def load_credentials credentials = redis.get redis_credentials_key JSON.parse(credentials) if credentials end |
#redis_credentials_key ⇒ Object
41 42 43 |
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 41 def redis_credentials_key @redis_credentials_key || DEFAULT_REDIS_CREDENTIALS_KEY end |
#write_credentials(credentials_hash) ⇒ Object
Write the credentials to redis.
49 50 51 |
# File 'lib/google/api_client/auth/storages/redis_store.rb', line 49 def write_credentials(credentials_hash) redis.set(redis_credentials_key, credentials_hash.to_json) end |