| 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 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | our $VERSION = '$Revision: 1.3 $'; | |||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | use Carp::Assert; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | use Class::MethodMaker | ||||||||||
| 15 | 1 | ▶ | 'new_with_init' => 'new', | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 'get_set' => [qw(one_key), | ||||||||||
| 17 | qw(many_key), | ||||||||||
| 18 | 1 | ]; | |||||||||
| 19 | |||||||||||
| 20 | ## new OneToMany($one_key, $many_key) | ||||||||||
| 21 | sub init | ||||||||||
| 22 | 0 | ▶ | { | ||||||||
|
Subroutine
init: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 23 | 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 | 0 | ▶ | { | ||||||||
|
Subroutine
one_table_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 37 | 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 | 0 | ▶ | { | ||||||||
|
Subroutine
many_table_info: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 0 | my $self = shift; | |||||||||
| 46 | 0 | assert(@_ == 0); | |||||||||
| 47 | 0 | $self->many_key->table_info; | |||||||||
| 48 | } | ||||||||||
| 49 | |||||||||||
| 50 | sub resolve | ||||||||||
| 51 | 0 | ▶ | { | ||||||||
|
Subroutine
resolve: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 52 | 0 | my $self = shift; | |||||||||
| 53 | 0 | ▶ | $self->many_key->resolve && $self->one_key->resolve; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | 1 | 1; | |||||||||
| 57 | __END__ | ||||||||||