Class: Google::Auth::Stores::FileTokenStore

Inherits:
TokenStore
  • Object
show all
Defined in:
lib/googleauth/stores/file_token_store.rb

Overview

Implementation of user token storage backed by a local YAML file

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ FileTokenStore

Create a new store with the supplied file.

Parameters:

  • file (String, File)

    Path to storage file



42
43
44
45
46
# File 'lib/googleauth/stores/file_token_store.rb', line 42

def initialize options = {}
  super()
  path = options[:file]
  @store = YAML::Store.new path
end

Instance Method Details

#delete(id) ⇒ Object



59
60
61
# File 'lib/googleauth/stores/file_token_store.rb', line 59

def delete id
  @store.transaction { @store.delete id }
end

#load(id) ⇒ Object



49
50
51
# File 'lib/googleauth/stores/file_token_store.rb', line 49

def load id
  @store.transaction { @store[id] }
end

#store(id, token) ⇒ Object



54
55
56
# File 'lib/googleauth/stores/file_token_store.rb', line 54

def store id, token
  @store.transaction { @store[id] = token }
end