Class: Procore::Auth::Stores::File

Inherits:
Object
  • Object
show all
Defined in:
lib/procore/auth/stores/file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key:, path:) ⇒ File

Returns a new instance of File.



8
9
10
11
12
# File 'lib/procore/auth/stores/file.rb', line 8

def initialize(key:, path:)
  @key = key
  @path = path
  @store = YAML::Store.new(path)
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



7
8
9
# File 'lib/procore/auth/stores/file.rb', line 7

def key
  @key
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/procore/auth/stores/file.rb', line 7

def path
  @path
end

Instance Method Details

#deleteObject



22
23
24
# File 'lib/procore/auth/stores/file.rb', line 22

def delete
  @store.transaction { @store.delete(key) }
end

#fetchObject



18
19
20
# File 'lib/procore/auth/stores/file.rb', line 18

def fetch
  @store.transaction { @store[key] }
end

#save(token) ⇒ Object



14
15
16
# File 'lib/procore/auth/stores/file.rb', line 14

def save(token)
  @store.transaction { @store[key] = token }
end

#to_sObject



26
27
28
# File 'lib/procore/auth/stores/file.rb', line 26

def to_s
  "File, Key: #{key}, Path: #{path}"
end