Sha256: bc99110564451c53cbda89e26ef1c458406b6ddc0a2035e1a80336ecd6432838

Contents?: true

Size: 621 Bytes

Versions: 16

Compression:

Stored size: 621 Bytes

Contents

require 'certmeister/store_error'

module Certmeister

  class InMemoryStore

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

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

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

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

    def health_check
      @healthy
    end

    private

    def break!
      @healthy = false
    end

    def fail_if_unhealthy
      raise Certmeister::StoreError.new("in-memory store is broken") if !@healthy
    end

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
certmeister-1.2.1 lib/certmeister/in_memory_store.rb
certmeister-1.2.0 lib/certmeister/in_memory_store.rb
certmeister-1.1.0 lib/certmeister/in_memory_store.rb
certmeister-1.0.1 lib/certmeister/in_memory_store.rb
certmeister-1.0.0 lib/certmeister/in_memory_store.rb
certmeister-0.4.1 lib/certmeister/in_memory_store.rb
certmeister-0.4.0 lib/certmeister/in_memory_store.rb
certmeister-0.3.2 lib/certmeister/in_memory_store.rb
certmeister-0.3.1 lib/certmeister/in_memory_store.rb
certmeister-0.3.0 lib/certmeister/in_memory_store.rb
certmeister-0.2.3 lib/certmeister/in_memory_store.rb
certmeister-0.2.1 lib/certmeister/in_memory_store.rb
certmeister-0.2.0 lib/certmeister/in_memory_store.rb
certmeister-0.1.0 lib/certmeister/in_memory_store.rb
certmeister-0.0.2 lib/certmeister/in_memory_store.rb
certmeister-0.0.1 lib/certmeister/in_memory_store.rb