File Coverage

blib/lib/DBomb/Meta/OneToMany.pm
Criterion Covered Total %
statement 12 25 48.0
branch 0 2 0.0
condition n/a
subroutine 4 8 50.0
pod 0 4 0.0
total 16 39 41.0


line stmt bran cond sub pod time code
1             package DBomb::Meta::OneToMany;
2              
3             =head1 NAME
4              
5             DBomb::Meta::OneToMany - A One to N relationship.
6              
7             =cut
8              
9 1     1   1817 use strict;
  1         3  
  1         38  
10 1     1   5 use warnings;
  1         3  
  1         52  
11             our $VERSION = '$Revision: 1.3 $';
12              
13 1     1   14 use Carp::Assert;
  1         2  
  1         11  
14             use Class::MethodMaker
15 1         11 'new_with_init' => 'new',
16             'get_set' => [qw(one_key),
17             qw(many_key),
18 1     1   186 ];
  1         3  
19              
20             ## new OneToMany($one_key, $many_key)
21             sub init
22             {
23 0     0 0   my ($self,$one_key,$many_key) = @_;
24              
25 0           assert(UNIVERSAL::isa($one_key,'DBomb::Meta::Key'), 'OneToMany->new requires a one_key');
26 0           assert(UNIVERSAL::isa($many_key,'DBomb::Meta::Key'), 'OneToMany->new requires a many_key');
27              
28 0           $self->one_key($one_key);
29 0           $self->many_key($many_key);
30              
31             ## TODO: Register with both tables?
32             }
33              
34             ## return the tableinfo for the "one" end of this relationship
35             sub one_table_info
36             {
37 0     0 0   my $self = shift;
38 0           assert(@_ == 0);
39 0           $self->one_key->table_info;
40             }
41              
42             ## return the tableinfo for the "many" end of this relationship
43             sub many_table_info
44             {
45 0     0 0   my $self = shift;
46 0           assert(@_ == 0);
47 0           $self->many_key->table_info;
48             }
49              
50             sub resolve
51             {
52 0     0 0   my $self = shift;
53 0 0         $self->many_key->resolve && $self->one_key->resolve;
54             }
55              
56             1;
57             __END__