Class: Imap::Backup::Mirror::Map
- Inherits:
-
Object
- Object
- Imap::Backup::Mirror::Map
- Defined in:
- lib/imap/backup/mirror/map.rb
Instance Method Summary collapse
- #check_uid_validities(source:, destination:) ⇒ Object
- #destination_uid(source_uid) ⇒ Object
-
#initialize(pathname:, destination:) ⇒ Map
constructor
A new instance of Map.
- #map_uids(source:, destination:) ⇒ Object
- #reset(source_uid_validity:, destination_uid_validity:) ⇒ Object
- #save ⇒ Object
- #source_uid(destination_uid) ⇒ Object
Constructor Details
#initialize(pathname:, destination:) ⇒ Map
Returns a new instance of Map.
9 10 11 12 13 14 15 16 17 |
# File 'lib/imap/backup/mirror/map.rb', line 9 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 Method Details
#check_uid_validities(source:, destination:) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/imap/backup/mirror/map.rb', line 19 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
44 45 46 47 48 49 50 |
# File 'lib/imap/backup/mirror/map.rb', line 44 def destination_uid(source_uid) if destination_store == {} raise "Assign UID validities with #reset before calling #destination_uid" end map[source_uid] end |
#map_uids(source:, destination:) ⇒ Object
52 53 54 55 56 |
# File 'lib/imap/backup/mirror/map.rb', line 52 def map_uids(source:, destination:) raise "Assign UID validities with #reset before calling #map_uids" if destination_store == {} map[source] = destination end |
#reset(source_uid_validity:, destination_uid_validity:) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/imap/backup/mirror/map.rb', line 27 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 |
#save ⇒ Object
58 59 60 |
# File 'lib/imap/backup/mirror/map.rb', line 58 def save File.write(pathname, store.to_json) end |
#source_uid(destination_uid) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/imap/backup/mirror/map.rb', line 36 def source_uid(destination_uid) if destination_store == {} raise "Assign UID validities with #reset before calling #source_uid" end map.key(destination_uid) end |