Class: Imap::Backup::Serializer::DelayedMetadataSerializer
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::DelayedMetadataSerializer
- Extended by:
- Forwardable
- Defined in:
- lib/imap/backup/serializer/delayed_metadata_serializer.rb
Instance Attribute Summary collapse
-
#serializer ⇒ Object
readonly
Returns the value of attribute serializer.
Instance Method Summary collapse
- #append(uid, message, flags) ⇒ Object
-
#initialize(serializer:) ⇒ DelayedMetadataSerializer
constructor
A new instance of DelayedMetadataSerializer.
- #transaction(&block) ⇒ Object
Constructor Details
#initialize(serializer:) ⇒ DelayedMetadataSerializer
Returns a new instance of DelayedMetadataSerializer.
15 16 17 18 |
# File 'lib/imap/backup/serializer/delayed_metadata_serializer.rb', line 15 def initialize(serializer:) @serializer = serializer @tsx = nil end |
Instance Attribute Details
#serializer ⇒ Object (readonly)
Returns the value of attribute serializer.
11 12 13 |
# File 'lib/imap/backup/serializer/delayed_metadata_serializer.rb', line 11 def serializer @serializer end |
Instance Method Details
#append(uid, message, flags) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/imap/backup/serializer/delayed_metadata_serializer.rb', line 32 def append(uid, , flags) tsx.fail_outside_transaction!(:append) = Email::Mboxrd::Message.new() serialized = .to_serialized tsx.data[:metadata] << {uid: uid, length: serialized.bytesize, flags: flags} mbox.append(serialized) end |
#transaction(&block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/imap/backup/serializer/delayed_metadata_serializer.rb', line 20 def transaction(&block) tsx.fail_in_transaction!(:transaction, message: "nested transactions are not supported") tsx.begin({metadata: []}) do mbox.transaction do block.call commit end end end |