line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBomb::Meta::HasA; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
DBomb::Meta::HasA - One side of a one-to-many relationship. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=cut |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
1334
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
10
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
11
|
|
|
|
|
|
|
our $VERSION = '$Revision: 1.4 $'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use Carp::Assert; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
10
|
|
14
|
|
|
|
|
|
|
use Class::MethodMaker |
15
|
1
|
|
|
|
|
8
|
'new_with_init' => 'new', |
16
|
|
|
|
|
|
|
'get_set' => [qw(one_to_many), ## The relationship object |
17
|
|
|
|
|
|
|
qw(attr), ## The accessor |
18
|
1
|
|
|
1
|
|
161
|
]; |
|
1
|
|
|
|
|
2
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
## new HasA($one_to_many, $opts) |
21
|
|
|
|
|
|
|
sub init |
22
|
|
|
|
|
|
|
{ |
23
|
0
|
|
|
0
|
0
|
|
my ($self, $one_to_many, $opts) = @_; |
24
|
0
|
|
0
|
|
|
|
$opts ||= {}; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
0
|
|
|
|
assert(2 <= @_ && @_ <= 3, 'parameter count'); |
27
|
0
|
|
|
|
|
|
assert(UNIVERSAL::isa($one_to_many,'DBomb::Meta::OneToMany'), 'HasA->new requires OneToMany'); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->one_to_many($one_to_many); |
30
|
|
|
|
|
|
|
$self->attr($opts->{'attr'} || join(q//, "_dbo_has_a_attr: ", |
31
|
|
|
|
|
|
|
$one_to_many->many_key->table_info->name, "(", |
32
|
|
|
|
|
|
|
join(', ', @{$one_to_many->many_key->column_names}), ") =>", |
33
|
|
|
|
|
|
|
$one_to_many->one_key->table_info->name, "(", |
34
|
0
|
|
0
|
|
|
|
join(', ', @{$one_to_many->one_key->column_names}), ") =>", |
35
|
|
|
|
|
|
|
)); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
## Register with table_info |
38
|
0
|
|
|
|
|
|
push @{$one_to_many->many_table_info->has_as}, $self; |
|
0
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub resolve |
42
|
|
|
|
|
|
|
{ |
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
return 1; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |
48
|
|
|
|
|
|
|
__END__ |