Class: GovFakeNotify::Store

Inherits:
Object
  • Object
show all
Defined in:
lib/gov_fake_notify/store.rb

Overview

A central store for storing all state in the app - uses a basic PStore

Class Method Summary collapse

Class Method Details

.clear_attachments!(config: Config.instance) ⇒ Object



23
24
25
# File 'lib/gov_fake_notify/store.rb', line 23

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

.clear_messages!Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/gov_fake_notify/store.rb', line 12

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

      instance.delete(key)
    end
  end
  clear_attachments!
end

.instanceObject



8
9
10
# File 'lib/gov_fake_notify/store.rb', line 8

def self.instance
  Thread.current[:gov_fake_notify_store] ||= ::PStore.new(GovFakeNotify.config.database_file)
end