| 1 | package DBIx::Class::Schema::TxnEndHook; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use 5.008005; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | sub add_txn_end_hook { | ||||||||||
| 8 | 2 | ▶ | my $self = shift; | ||||||||
|
Subroutine
add_txn_end_hook: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | $self->storage or $self->throw_exception | ||||||||
|
Branch: 1 branch
| |||||||||||
| 11 | ('add_txn_end_hook called on $schema without storage'); | ||||||||||
| 12 | |||||||||||
| 13 | 2 | $self->storage->add_txn_end_hook(@_); | |||||||||
| 14 | } | ||||||||||
| 15 | |||||||||||
| 16 | 2 | 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<add_txn_end_hook> 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 | ||||||||||