Class: Keyring::Backend::Memory

Inherits:
Keyring::Backend show all
Defined in:
lib/keyring/backends/memory.rb

Overview

Stores the keyring in-memory. Useful when you don't need permanant storage.

Instance Method Summary collapse

Methods inherited from Keyring::Backend

create, register_implementation

Constructor Details

#initializeMemory

Returns a new instance of Memory.


9
10
11
# File 'lib/keyring/backends/memory.rb', line 9

def initialize
  @keyring = {}
end

Instance Method Details

#delete_password(service, username) ⇒ Object


26
27
28
# File 'lib/keyring/backends/memory.rb', line 26

def delete_password(service, username)
  @keyring[service] && @keyring[service].delete(username)
end

#get_password(service, username) ⇒ Object


19
20
21
# File 'lib/keyring/backends/memory.rb', line 19

def get_password(service, username)
  @keyring[service] && @keyring[service][username]
end

#priorityObject


15
16
17
# File 'lib/keyring/backends/memory.rb', line 15

def priority
  0.1
end

#set_password(service, username, password) ⇒ Object


22
23
24
25
# File 'lib/keyring/backends/memory.rb', line 22

def set_password(service, username, password)
  @keyring[service] ||= {}
  @keyring[service][username] = password
end

#supported?Boolean

Returns:

  • (Boolean)

12
13
14
# File 'lib/keyring/backends/memory.rb', line 12

def supported?
  true
end