1 package File
::KDBX
::Transaction
;
2 # ABSTRACT: Make multiple database edits atomically
7 use Devel
::GlobalDestruction
;
10 our $VERSION = '999.999'; # VERSION
14 $txn = File
::KDBX
::Transaction-
>new($object);
16 Construct a new database transaction
for editing an object atomically
.
23 $object->begin_work(@_);
24 return bless {object
=> $object}, $class;
27 sub DESTROY
{ !in_global_destruction
and $_[0]->rollback }
31 Get the object being transacted on
.
35 sub object
{ $_[0]->{object
} }
41 Commit the transaction
, making updates to the L
</object
> permanent
.
47 return if $self->{done
};
49 my $obj = $self->object;
59 Roll back the transaction
, throwing away any updates to the L
</object
> made since the transaction began
. This
60 happens automatically
when the transaction
is released
, unless it
has already been committed
.
66 return if $self->{done
};
68 my $obj = $self->object;