Class: Fog::Backblaze::TokenCache::FileTokenCache
- Inherits:
-
Fog::Backblaze::TokenCache
- Object
- Fog::Backblaze::TokenCache
- Fog::Backblaze::TokenCache::FileTokenCache
- Defined in:
- lib/fog/backblaze/token_cache.rb
Overview
stored in local file
Constant Summary
Constants inherited from Fog::Backblaze::TokenCache
Instance Method Summary collapse
-
#initialize(file) ⇒ FileTokenCache
constructor
A new instance of FileTokenCache.
- #load_data ⇒ Object
- #save_data ⇒ Object
Methods inherited from Fog::Backblaze::TokenCache
#access_part, #auth_response, #auth_response=, #buckets, #buckets=, #fetch, #reset, #upload_url, #write_part
Constructor Details
#initialize(file) ⇒ FileTokenCache
Returns a new instance of FileTokenCache.
106 107 108 109 |
# File 'lib/fog/backblaze/token_cache.rb', line 106 def initialize(file) @file = file super() end |
Instance Method Details
#load_data ⇒ Object
111 112 113 114 115 116 117 |
# File 'lib/fog/backblaze/token_cache.rb', line 111 def load_data if File.exist?(@file) ::JSON.parse(File.open(@file, 'rb', &:read)) else {} end end |
#save_data ⇒ Object
119 120 121 122 123 |
# File 'lib/fog/backblaze/token_cache.rb', line 119 def save_data File.open(@file, 'wb') do |f| f.write(::JSON.pretty_generate(@data) + "\n") end end |