Module: DasCatalog::Store

Extended by:
Store
Included in:
Store
Defined in:
lib/das_catalog/store.rb

Defined Under Namespace

Classes: UUIDMismatch

Instance Method Summary collapse

Instance Method Details

#allObject



27
28
29
30
31
32
33
# File 'lib/das_catalog/store.rb', line 27

def all
  pstore.transaction(true) do
    pstore.roots.collect do |name|
      pstore[name]
    end
  end
end

#find(id) ⇒ Object



21
22
23
24
25
# File 'lib/das_catalog/store.rb', line 21

def find(id)
  pstore.transaction(true) do
    pstore[id]
  end
end

#pstoreObject



9
10
11
# File 'lib/das_catalog/store.rb', line 9

def pstore
  @pstore ||= PStore.new(DasCatalog.tracker_file)
end

#resetObject



13
14
15
16
17
18
19
# File 'lib/das_catalog/store.rb', line 13

def reset
  pstore.transaction do
    pstore.roots.each do |key|
      pstore.delete key
    end
  end
end

#store(screencast_data) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/das_catalog/store.rb', line 35

def store(screencast_data)
  if sd = find(screencast_data.id)
    raise UUIDMismatch if sd.uuid && sd.uuid != screencast_data.uuid
  end

  pstore.transaction do
    pstore[screencast_data.id] = screencast_data
  end
end