Sha256: 04694405d827dd1a63e59a6cf7330369dd7bac97aa098756144b4b16f0c1b693
Contents?: true
Size: 921 Bytes
Versions: 2
Compression:
Stored size: 921 Bytes
Contents
require "json" module BingAdsRubySdk module OAuth2 # Oauth2 token default non-encrypted File System store class FsStore # @param filename [String] the uniq filename to identify filename storing data. def initialize(filename) @filename = filename end # Writes the token to file # @return [File] if the file was written (doesn't mean the token is). # @return [self] if the filename don't exist. def write(value) return nil unless filename File.open(filename, "w") { |f| JSON.dump(value, f) } self end # Reads the token from file # @return [Hash] if the token information that was stored. # @return [nil] if the file doesn't exist. def read return nil unless File.file?("./#{filename}") JSON.parse(File.read(filename)) end private attr_reader :filename end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bing_ads_ruby_sdk-1.7 | lib/bing_ads_ruby_sdk/oauth2/fs_store.rb |
bing_ads_ruby_sdk-1.6 | lib/bing_ads_ruby_sdk/oauth2/fs_store.rb |