line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Transactional; |
2
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
8221
|
use Catmandu::Sane; |
|
16
|
|
|
|
|
43
|
|
|
16
|
|
|
|
|
144
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.2020'; |
6
|
|
|
|
|
|
|
|
7
|
16
|
|
|
16
|
|
123
|
use Moo::Role; |
|
16
|
|
|
|
|
51
|
|
|
16
|
|
|
|
|
158
|
|
8
|
16
|
|
|
16
|
|
6499
|
use namespace::clean; |
|
16
|
|
|
|
|
40
|
|
|
16
|
|
|
|
|
122
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
requires 'transaction'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__END__ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=pod |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
Catmandu::Transactional - Optional role for transactional stores |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# bag will be untouched |
25
|
|
|
|
|
|
|
my $store->transaction(sub { |
26
|
|
|
|
|
|
|
$store->bag('books')->add({title => 'Time must have a stop'}); |
27
|
|
|
|
|
|
|
die; |
28
|
|
|
|
|
|
|
}); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 transaction($sub) |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
C<transaction> takes a coderef that will be executed in the context of a |
35
|
|
|
|
|
|
|
transaction. If an error is thrown, the transaction will rollback. If the code |
36
|
|
|
|
|
|
|
executes successfully, the transaction will be committed. There is no support |
37
|
|
|
|
|
|
|
for nested transactions, nested calls to C<transaction> will simply be subsumed |
38
|
|
|
|
|
|
|
by their parent transaction. |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |