Class: Remotus::Auth::HashStore

Inherits:
Store
  • Object
show all
Defined in:
lib/remotus/auth/hash_store.rb

Overview

Hash-based authentication store that requires credentials to be added manually

Instance Method Summary collapse

Methods inherited from Store

#password, #user

Constructor Details

#initializeHashStore

Creates the HashStore



10
11
12
13
# File 'lib/remotus/auth/hash_store.rb', line 10

def initialize
  super
  @store = {}
end

Instance Method Details

#add(connection, credential) ⇒ Object

Adds a credential to the store for a given connection

Parameters:



33
34
35
# File 'lib/remotus/auth/hash_store.rb', line 33

def add(connection, credential)
  @store[connection.host.downcase] = credential
end

#credential(connection, **_options) ⇒ Remotus::Auth::Credential?

Retrieves a credential from the hash store

Parameters:

Returns:



23
24
25
# File 'lib/remotus/auth/hash_store.rb', line 23

def credential(connection, **_options)
  @store[connection.host.downcase]
end

#remove(connection) ⇒ Object

Removes a credential from the store for a given connection

Parameters:



42
43
44
# File 'lib/remotus/auth/hash_store.rb', line 42

def remove(connection)
  @store.delete(connection.host.downcase)
end

#to_sString

String representation of the hash store

Returns:

  • (String)

    string representation of the hash store



51
52
53
# File 'lib/remotus/auth/hash_store.rb', line 51

def to_s
  "HashStore"
end