Class: Imap::Backup::LocalOnlyMessageDeleter
- Inherits:
-
Object
- Object
- Imap::Backup::LocalOnlyMessageDeleter
- Defined in:
- lib/imap/backup/local_only_message_deleter.rb
Instance Attribute Summary collapse
-
#folder ⇒ Object
readonly
Returns the value of attribute folder.
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
-
#initialize(folder, serializer) ⇒ LocalOnlyMessageDeleter
constructor
A new instance of LocalOnlyMessageDeleter.
-
#run ⇒ Object
TODO: this method is very slow as it copies all messages.
Constructor Details
#initialize(folder, serializer) ⇒ LocalOnlyMessageDeleter
Returns a new instance of LocalOnlyMessageDeleter.
8 9 10 11 |
# File 'lib/imap/backup/local_only_message_deleter.rb', line 8 def initialize(folder, serializer) @folder = folder @serializer = serializer end |
Instance Attribute Details
#folder ⇒ Object (readonly)
Returns the value of attribute folder.
5 6 7 |
# File 'lib/imap/backup/local_only_message_deleter.rb', line 5 def folder @folder end |
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
6 7 8 |
# File 'lib/imap/backup/local_only_message_deleter.rb', line 6 def serializer @serializer end |
Instance Method Details
#run ⇒ Object
TODO: this method is very slow as it copies all messages. A quicker method would only remove UIDs from the .imap file, but that would require a garbage collection later.
16 17 18 19 20 21 22 23 |
# File 'lib/imap/backup/local_only_message_deleter.rb', line 16 def run local_only_uids = serializer.uids - folder.uids return if local_only_uids.empty? serializer.filter do || !local_only_uids.include?(.uid) end end |