File Coverage

blib/lib/DBIx/Class/Schema/TxnEndHook.pm
Criterion Covered Total %
statement 12 12 100.0
branch 1 2 50.0
condition n/a
subroutine 4 4 100.0
pod 1 1 100.0
total 18 19 94.7


line stmt bran cond sub pod time code
1             package DBIx::Class::Schema::TxnEndHook;
2              
3 2     2   31058 use 5.008005;
  2         6  
  2         66  
4 2     2   169 use strict;
  2         4  
  2         54  
5 2     2   7 use warnings;
  2         2  
  2         195  
6              
7             sub add_txn_end_hook {
8 2     2 1 875 my $self = shift;
9              
10 2 50       41 $self->storage or $self->throw_exception
11             ('add_txn_end_hook called on $schema without storage');
12              
13 2         53 $self->storage->add_txn_end_hook(@_);
14             }
15              
16             1;
17              
18             =encoding utf-8
19              
20             =head1 NAME
21              
22             DBIx::Class::Schema::TxnEndHook - provide add_txn_end_hook method to your schema class
23              
24             =head1 SYNOPSIS
25              
26             package MyApp::Schema;
27             use parent 'DBIx::Schema';
28             __PACKAGE__->ensure_class_loaded('DBIx::Class::Storage::TxnEndHook');
29             __PACKAGE__->ensure_class_loaded('DBIx::Class::Storage::DBI');
30             __PACKAGE__->inject_base('DBIx::Class::Storage::DBI', 'DBIx::Class::Storage::TxnEndHook');
31             __PACKAGE__->load_components('Schema::TxnEndHook');
32              
33             package main
34              
35             my $schema = MyApp::Schema->connect(...)
36             $schema->txn_begin;
37             $schema->add_txn_end_hook(sub { ... });
38             $schema->txn_commit;
39              
40             =head1 DESCRIPTION
41              
42             DBIx::Class::Schema::TxnEndHook provide C method to your schema class.
43              
44             =head1 METHODS
45              
46             =over 4
47              
48             =item $schema->add_txn_end_hook(sub{ ... })
49              
50             It is short cut for C<< $schema->storage->add_txn_end_hook(sub{ ... }) >>.
51              
52             =back