File Coverage

blib/lib/Catmandu/Transactional.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


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