Class: Certmeister::InMemoryStore

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/certmeister/in_memory_store.rb

Instance Method Summary collapse

Constructor Details

#initialize(certs = {}) ⇒ InMemoryStore

Returns a new instance of InMemoryStore.



9
10
11
12
# File 'lib/certmeister/in_memory_store.rb', line 9

def initialize(certs = {})
  @certs = certs
  @healthy = true
end

Instance Method Details

#eachObject



29
30
31
32
33
# File 'lib/certmeister/in_memory_store.rb', line 29

def each
  @certs.each do |cn, cert|
    yield cn, cert
  end
end

#fetch(cn) ⇒ Object



19
20
21
22
# File 'lib/certmeister/in_memory_store.rb', line 19

def fetch(cn)
  fail_if_unhealthy
  @certs[cn]
end

#health_checkObject



35
36
37
# File 'lib/certmeister/in_memory_store.rb', line 35

def health_check
  @healthy
end

#remove(cn) ⇒ Object



24
25
26
27
# File 'lib/certmeister/in_memory_store.rb', line 24

def remove(cn)
  fail_if_unhealthy
  !!@certs.delete(cn)
end

#store(cn, cert) ⇒ Object



14
15
16
17
# File 'lib/certmeister/in_memory_store.rb', line 14

def store(cn, cert)
  fail_if_unhealthy
  @certs[cn] = cert
end