← Index
NYTProf Performance Profile   « block view • line view • sub view »
For ddd2.pl
  Run on Tue May 25 16:52:24 2010
Reported on Tue May 25 16:57:04 2010

File /project/perl/lib/Class/DBI/Cascade/None.pm
Statements Executed 11
Statement Execution Time 493µs
Subroutines — ordered by exclusive time
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
21199µs99µsClass::DBI::Cascade::None::::newClass::DBI::Cascade::None::new
0000s0sClass::DBI::Cascade::None::::BEGINClass::DBI::Cascade::None::BEGIN
0000s0sClass::DBI::Cascade::None::::cascadeClass::DBI::Cascade::None::cascade
0000s0sClass::DBI::Cascade::None::::foreign_forClass::DBI::Cascade::None::foreign_for
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Class::DBI::Cascade::None;
2
3=head1 NAME
4
5Class::DBI::Cascade::None - Do nothing upon deletion
6
7=head1 DESCRIPTION
8
9This is a Cascading Delete strategy that will do nothing, leaving
10orphaned records behind.
11
12It is the base class for most ofther Cascade strategies, and so provides
13several important methods:
14
15=head1 CONSTRUCTOR
16
17=head2 new
18
19 my $strategy = Cascade::Class->new($Relationship);
20
21This must be instantiated with a Class::DBI::Relationship object.
22
23=head1 METHODS
24
25=head2 foreign_for
26
27 my $iterator = $strategy->foreign_for($obj);
28
29This will return all the objects which are foreign to $obj across the
30relationship. It's a normal Class::DBI search you can get the results
31either as a list or as an iterator.
32
33=head2 cascade
34
35 $strategy->cascade($obj);
36
37Cascade across the related objects to $obj.
38
39=head1 WRITING NEW STRATEGIES
40
41Creating a Cascade strategy should be fairly simple. You usually just
42need to inherit from here, and then supply a cascade() method that does
43the required thing with the results from foreign_for().
44
45So, for example, Cascade::Delete is implemented simply as:
46
47 package Class::DBI::Cascade::Delete;
48
49 use base 'Class::DBI::Cascade::None';
50
51 sub cascade {
52 my ($self, $obj) = @_;
53 $self->foreign_for($obj)->delete_all;
54 }
55
56=cut
57
58387µs126µsuse strict;
# spent 26µs making 1 call to strict::import
593285µs1116µsuse warnings;
# spent 116µs making 1 call to warnings::import
60
61
# spent 99µs within Class::DBI::Cascade::None::new which was called 2 times, avg 50µs/call: # 2 times (99µs+0s) by Class::DBI::Relationship::HasMany::triggers at line 74 of Class/DBI/Relationship/HasMany.pm, avg 50µs/call
sub new {
62215µs my ($class, $rel) = @_;
63294µs bless { _rel => $rel } => $class;
64}
65
66sub foreign_for {
67 my ($self, $obj) = @_;
68 return $self->{_rel}
69 ->foreign_class->search($self->{_rel}->args->{foreign_key} => $obj->id);
70}
71
72sub cascade { return; }
73
74112µs1;