Class: Keyring::Backend

Inherits:
Object
  • Object
show all
Defined in:
lib/keyring/backend.rb

Overview

keyring: System keyring abstraction library License: MIT (www.opensource.org/licenses/mit-license.php)

Direct Known Subclasses

GnomeKeyring, MacosxKeychain, Memory

Defined Under Namespace

Classes: GnomeKeyring, MacosxKeychain, Memory

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.implementationsObject

Returns the value of attribute implementations


7
8
9
# File 'lib/keyring/backend.rb', line 7

def implementations
  @implementations
end

Class Method Details

.createObject


13
14
15
16
17
18
19
# File 'lib/keyring/backend.rb', line 13

def self.create
  supported = implementations.collect{|i| b = i.new; b.supported? ? b : nil}.compact
  if supported.empty?
    raise(NotImplementedError)
  end
  supported.max{|a, b| a.priority <=> b.priority }
end

.register_implementation(impl) ⇒ Object


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

def self.register_implementation(impl)
  Keyring::Backend.implementations << impl
end

Instance Method Details

#delete_password(service, username) ⇒ Object

Raises:

  • (NotImplementedError)

39
40
41
# File 'lib/keyring/backend.rb', line 39

def delete_password(service, username)
  raise NotImplementedError
end

#get_password(service, username) ⇒ Object

Raises:

  • (NotImplementedError)

36
37
38
# File 'lib/keyring/backend.rb', line 36

def get_password(service, username)
  raise NotImplementedError
end

#priorityObject

Returns a number between 0 and 1 (inclusive) indicating the relative preference for this backend.


30
31
32
# File 'lib/keyring/backend.rb', line 30

def priority
  0
end

#set_password(service, username, password) ⇒ Object

Raises:

  • (NotImplementedError)

33
34
35
# File 'lib/keyring/backend.rb', line 33

def set_password(service, username, password)
  raise NotImplementedError
end

#supported?Boolean

Backend classes must implement these methods

Returns:

  • (Boolean)

25
26
27
# File 'lib/keyring/backend.rb', line 25

def supported?
  false
end