Class: FactorySeeder::ExecutionLogStore

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_seeder/execution_log_store.rb

Overview

Temporary in-memory storage for execution logs Used to implement PRG pattern without session overflow

Constant Summary collapse

EXPIRY_TIME =

5 minutes

300

Class Method Summary collapse

Class Method Details

.clearObject



32
33
34
# File 'lib/factory_seeder/execution_log_store.rb', line 32

def clear
  @storage = {}
end

.retrieve(id) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/factory_seeder/execution_log_store.rb', line 22

def retrieve(id)
  return nil if id.blank?

  cleanup_expired
  data = storage.delete(id)
  return nil unless data

  data
end

.store(logs, flash_type: nil, flash_message: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/factory_seeder/execution_log_store.rb', line 10

def store(logs, flash_type: nil, flash_message: nil)
  cleanup_expired
  id = SecureRandom.hex(8)
  storage[id] = {
    logs: logs,
    flash_type: flash_type,
    flash_message: flash_message,
    created_at: Time.now
  }
  id
end