| 1 | package EntityModel::Field; | ||||||||||||
| 2 | { | ||||||||||||
| 3 | 53 | $EntityModel::Field::VERSION = '0.102'; | |||||||||||
| 4 | } | ||||||||||||
| 5 | 53 | ▶ | use EntityModel::Class { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 53 | 'name' => { type => 'string' }, | |||||||||||
| 7 | 'default' => { type => 'string' }, | ||||||||||||
| 8 | 'null' => { type => 'bool' }, | ||||||||||||
| 9 | 'type' => { type => 'string' }, | ||||||||||||
| 10 | 'length' => { type => 'int' }, | ||||||||||||
| 11 | 'description' => { type => 'string' }, | ||||||||||||
| 12 | 'precision' => { type => 'int' }, | ||||||||||||
| 13 | 'scale' => { type => 'int' }, | ||||||||||||
| 14 | 'unique' => { type => 'bool' }, | ||||||||||||
| 15 | 'refer' => { type => 'EntityModel::Field::Refer' }, | ||||||||||||
| 16 | 53 | }; | |||||||||||
| 17 | |||||||||||||
| 18 | 53 | ▶ | use overload '""' => sub { 'field:' . shift->name }, fallback => 1; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | |||||||||||||
| 20 | =head1 NAME | ||||||||||||
| 21 | |||||||||||||
| 22 | EntityModel::Field - field definitions for L<EntityModel> | ||||||||||||
| 23 | |||||||||||||
| 24 | =head1 VERSION | ||||||||||||
| 25 | |||||||||||||
| 26 | version 0.102 | ||||||||||||
| 27 | |||||||||||||
| 28 | =head1 SYNOPSIS | ||||||||||||
| 29 | |||||||||||||
| 30 | See L<EntityModel>. | ||||||||||||
| 31 | |||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||
| 33 | |||||||||||||
| 34 | See L<EntityModel>. | ||||||||||||
| 35 | |||||||||||||
| 36 | =cut | ||||||||||||
| 37 | |||||||||||||
| 38 | 0 | ▶ | sub method { shift->name } | ||||||||||
|
Subroutine
method: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 39 | |||||||||||||
| 40 | 34 | ▶ | sub create_from_definition { | ||||||||||
|
Subroutine
create_from_definition: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||
| 41 | 34 | my $class = shift; | |||||||||||
| 42 | 34 | my $def = shift; | |||||||||||
| 43 | 34 | my $self = $class->new; | |||||||||||
| 44 | |||||||||||||
| 45 | # Should only have one of these but we treat all nested elements as arrays in our definitions. | ||||||||||||
| 46 | 34 | ▶ | foreach my $refer_def (@{delete($def->{refer}) // []}) { | ||||||||||
|
Condition100%2/2
delete $def->{"refer"} // []
MC/DC100%1/1
delete $def->{"refer"} // []
delete $def->{"refer"}
Truth table100%2/2
A
A= delete $def->{"refer"}
| |||||||||||||
| 47 | 3 | my $refer = EntityModel::Field::Refer->new; | |||||||||||
| 48 | 3 | $refer->$_($refer_def->{$_}) foreach keys %$refer_def; | |||||||||||
| 49 | 3 | $self->refer($refer); | |||||||||||
| 50 | } | ||||||||||||
| 51 | |||||||||||||
| 52 | # Use the accessors so that we die satisfactorily when provided with anything invalid. | ||||||||||||
| 53 | 34 | $self->$_($def->{$_}) foreach keys %$def; | |||||||||||
| 54 | 34 | return $self; | |||||||||||
| 55 | } | ||||||||||||
| 56 | |||||||||||||
| 57 | 53 | 1; | |||||||||||
| 58 | |||||||||||||
| 59 | __END__ | ||||||||||||