Class: Imap::Backup::Mirror::Map

Inherits:
Object
  • Object
show all
Defined in:
lib/imap/backup/mirror/map.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pathname:, destination:) ⇒ Map

Returns a new instance of Map.


8
9
10
11
12
13
14
15
16
# File 'lib/imap/backup/mirror/map.rb', line 8

def initialize(pathname:, destination:)
  @pathname = pathname
  @destination = destination
  @store = nil
  @destination_store = nil
  @source_uid_validity = nil
  @destination_uid_validity = nil
  @map = nil
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.


6
7
8
# File 'lib/imap/backup/mirror/map.rb', line 6

def destination
  @destination
end

#pathnameObject (readonly)

Returns the value of attribute pathname.


5
6
7
# File 'lib/imap/backup/mirror/map.rb', line 5

def pathname
  @pathname
end

Instance Method Details

#check_uid_validities(source:, destination:) ⇒ Object


18
19
20
21
22
23
24
# File 'lib/imap/backup/mirror/map.rb', line 18

def check_uid_validities(source:, destination:)
  store
  return false if source != source_uid_validity
  return false if destination != destination_uid_validity

  true
end

#destination_uid(source_uid) ⇒ Object


39
40
41
# File 'lib/imap/backup/mirror/map.rb', line 39

def destination_uid(source_uid)
  map[source_uid]
end

#map_uids(source:, destination:) ⇒ Object


43
44
45
# File 'lib/imap/backup/mirror/map.rb', line 43

def map_uids(source:, destination:)
  map[source] = destination
end

#reset(source_uid_validity:, destination_uid_validity:) ⇒ Object


26
27
28
29
30
31
32
33
# File 'lib/imap/backup/mirror/map.rb', line 26

def reset(source_uid_validity:, destination_uid_validity:)
  destination_store["source_uid_validity"] = source_uid_validity
  @source_uid_validity = nil
  destination_store["destination_uid_validity"] = destination_uid_validity
  @destination_uid_validity = nil
  destination_store["map"] = {}
  @map = nil
end

#saveObject


47
48
49
# File 'lib/imap/backup/mirror/map.rb', line 47

def save
  File.write(pathname, store.to_json)
end

#source_uid(destination_uid) ⇒ Object


35
36
37
# File 'lib/imap/backup/mirror/map.rb', line 35

def source_uid(destination_uid)
  map.key(destination_uid)
end