DBI/Cascade/Fail.pm untested

filter: Statementstmt 0.0% 0 / 12 Branchbran n/a Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 20 CC 1 SCAR 6.9
CC
1
Cov
0%
cascade
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Class::DBI::Cascade::Fail;
2  
3 =head1 NAME
4  
5 Class::DBI::Cascade::Fail - Do not cascade if foreign objects exist
6  
7 =head1 DESCRIPTION
8  
9 This is a Cascading Delete strategy that will throw an error if any
10 object about to be deleted still has any other objects pointing at it.
11  
12 =cut
13  
14 use strict;
15 use warnings;
16  
17 use base 'Class::DBI::Cascade::None';
18  
19 sub cascade {
20 my ($self, $obj) = @_;
21 my $refs = $self->foreign_for($obj)->count or return;
22 $self->{_rel}->foreign_class->_croak(
23 "$refs objects still refer to $obj. Deletion failed");
24 }
25  
26 1;