Class: Imap::Backup::Serializer::Transaction
- Inherits:
-
Object
- Object
- Imap::Backup::Serializer::Transaction
- Defined in:
- lib/imap/backup/serializer/transaction.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
Instance Method Summary collapse
- #begin(data, &block) ⇒ Object
- #clear ⇒ Object
- #fail_in_transaction!(method, message: "not supported inside trasactions") ⇒ Object
- #fail_outside_transaction!(method) ⇒ Object
- #in_transaction? ⇒ Boolean
-
#initialize(owner:) ⇒ Transaction
constructor
A new instance of Transaction.
Constructor Details
#initialize(owner:) ⇒ Transaction
Returns a new instance of Transaction.
7 8 9 10 11 |
# File 'lib/imap/backup/serializer/transaction.rb', line 7 def initialize(owner:) @data = nil @owner = owner @in_transaction = false end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/imap/backup/serializer/transaction.rb', line 5 def data @data end |
Instance Method Details
#begin(data, &block) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/imap/backup/serializer/transaction.rb', line 13 def begin(data, &block) @data = data @in_transaction = true block.call @in_transaction = false end |
#clear ⇒ Object
20 21 22 |
# File 'lib/imap/backup/serializer/transaction.rb', line 20 def clear @data = nil end |
#fail_in_transaction!(method, message: "not supported inside trasactions") ⇒ Object
28 29 30 |
# File 'lib/imap/backup/serializer/transaction.rb', line 28 def fail_in_transaction!(method, message: "not supported inside trasactions") raise "#{owner.class}##{method} #{}" if in_transaction? end |
#fail_outside_transaction!(method) ⇒ Object
32 33 34 |
# File 'lib/imap/backup/serializer/transaction.rb', line 32 def fail_outside_transaction!(method) raise "#{owner.class}##{method} can only be called inside a transaction" if !in_transaction? end |
#in_transaction? ⇒ Boolean
24 25 26 |
# File 'lib/imap/backup/serializer/transaction.rb', line 24 def in_transaction? @in_transaction end |