Class: BingAdsRubySdk::OAuth2::FsStore
- Inherits:
-
Object
- Object
- BingAdsRubySdk::OAuth2::FsStore
- Defined in:
- lib/bing_ads_ruby_sdk/oauth2/fs_store.rb
Overview
Oauth2 token default non-encrypted File System store
Instance Method Summary collapse
-
#initialize(filename) ⇒ FsStore
constructor
A new instance of FsStore.
-
#read ⇒ Hash?
Reads the token from file.
-
#write(value) ⇒ File, self
Writes the token to file.
Constructor Details
#initialize(filename) ⇒ FsStore
Returns a new instance of FsStore.
8 9 10 |
# File 'lib/bing_ads_ruby_sdk/oauth2/fs_store.rb', line 8 def initialize(filename) @filename = filename end |
Instance Method Details
#read ⇒ Hash?
Reads the token from file
24 25 26 27 |
# File 'lib/bing_ads_ruby_sdk/oauth2/fs_store.rb', line 24 def read return nil unless File.file?("./#{filename}") JSON.parse(File.read(filename)) end |
#write(value) ⇒ File, self
Writes the token to file
15 16 17 18 19 |
# File 'lib/bing_ads_ruby_sdk/oauth2/fs_store.rb', line 15 def write(value) return nil unless filename File.open(filename, "w") { |f| JSON.dump(value, f) } self end |