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.
-
#owner ⇒ Object
readonly
Returns the value of attribute owner.
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.
8 9 10 11 12 |
# File 'lib/imap/backup/serializer/transaction.rb', line 8 def initialize(owner:) @data = nil @owner = owner @in_transaction = false end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
6 7 8 |
# File 'lib/imap/backup/serializer/transaction.rb', line 6 def data @data end |
#owner ⇒ Object (readonly)
Returns the value of attribute owner.
5 6 7 |
# File 'lib/imap/backup/serializer/transaction.rb', line 5 def owner @owner end |
Instance Method Details
#begin(data, &block) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/imap/backup/serializer/transaction.rb', line 14 def begin(data, &block) @data = data @in_transaction = true block.call @in_transaction = false end |
#clear ⇒ Object
21 22 23 |
# File 'lib/imap/backup/serializer/transaction.rb', line 21 def clear @data = nil end |
#fail_in_transaction!(method, message: "not supported inside trasactions") ⇒ Object
29 30 31 |
# File 'lib/imap/backup/serializer/transaction.rb', line 29 def fail_in_transaction!(method, message: "not supported inside trasactions") raise "#{owner.class}##{method} #{}" if in_transaction? end |
#fail_outside_transaction!(method) ⇒ Object
33 34 35 |
# File 'lib/imap/backup/serializer/transaction.rb', line 33 def fail_outside_transaction!(method) raise "#{owner.class}##{method} can only be called inside a transaction" if !in_transaction? end |
#in_transaction? ⇒ Boolean
25 26 27 |
# File 'lib/imap/backup/serializer/transaction.rb', line 25 def in_transaction? @in_transaction end |