line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Class::DBI::Cascade::Plugin::Nullify; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
155748
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base 'Class::DBI::Cascade::None'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
935
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 0.05; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub cascade { |
11
|
0
|
|
|
0
|
1
|
|
my ($self, $obj) = @_; |
12
|
0
|
|
|
|
|
|
my $foreign_objects = $self->foreign_for($obj); # get all foreign objects |
13
|
0
|
|
|
|
|
|
my $foreign_key = $self->{_rel}->args->{foreign_key}; # get the foreign key |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
while ( my $foreign_object = $foreign_objects->next) { |
16
|
0
|
|
|
|
|
|
$foreign_object->$foreign_key(undef); # set foreign key value to null |
17
|
0
|
|
|
|
|
|
$foreign_object->update(); # update the object |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
1; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
__END__ |