Sha256: ca07799e9ec6bc6fbc08526bf095d6d73b640eedc024b54e8842c4d151b04d60

Contents?: true

Size: 669 Bytes

Versions: 5

Compression:

Stored size: 669 Bytes

Contents

# frozen_string_literal: true

require 'singleton'
require 'pstore'
module GovFakeNotify
  # A central store for storing all state in the app - uses a basic PStore
  class Store
    def self.instance
      Thread.current[:gov_fake_notify_store] ||= ::PStore.new(GovFakeNotify.config.database_file)
    end

    def self.clear_messages!
      instance.transaction do
        instance.roots.each do |key|
          next unless key =~ /^message-/

          instance.delete(key)
        end
      end
      clear_attachments!
    end

    def self.clear_attachments!(config: Config.instance)
      FileUtils.rm_rf File.join(config.attachments_path, '.')
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gov_fake_notify-2.0.0 lib/gov_fake_notify/store.rb
gov_fake_notify-1.2.0 lib/gov_fake_notify/store.rb
gov_fake_notify-1.1.3 lib/gov_fake_notify/store.rb
gov_fake_notify-1.1.2 lib/gov_fake_notify/store.rb
gov_fake_notify-1.1.1 lib/gov_fake_notify/store.rb