| 1 | package File::DataClass::ResultSource; | ||||||||||||
| 2 | |||||||||||||
| 3 | 3 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 3 | ▶ | use File::DataClass::Constants qw( FALSE NUL TRUE ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | ▶ | use File::DataClass::ResultSet; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 3 | ▶ | use File::DataClass::Types qw( ArrayRef ClassName HashRef | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | Object SimpleStr Str ); | |||||||||||
| 9 | 3 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | # Private functions | ||||||||||||
| 12 | 1 | ▶ | my $_build_attributes = sub { | ||||||||||
|
Subroutine
_build__attributes: called CC=2 SCAR=9.2
Subroutine
__ANON__: not called CC=2 SCAR=9.2
| |||||||||||||
| 13 | 0 | my $self = shift; my $attr = {}; | |||||||||||
| 14 | |||||||||||||
| 15 | 0 | $attr->{ $_ } = TRUE for (@{ $self->attributes }); | |||||||||||
| 16 | |||||||||||||
| 17 | 0 | return $attr; | |||||||||||
| 18 | 3 | }; | |||||||||||
| 19 | |||||||||||||
| 20 | # Public attributes | ||||||||||||
| 21 | 3 | has 'attributes' => is => 'ro', isa => ArrayRef[Str], | |||||||||||
| 22 | required => TRUE; | ||||||||||||
| 23 | |||||||||||||
| 24 | 3 | ▶ | has 'defaults' => is => 'ro', isa => HashRef, builder => sub { {} }; | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
Subroutine
_build_defaults: called CC=1 SCAR=0.0
| |||||||||||||
| 25 | |||||||||||||
| 26 | 3 | has 'name' => is => 'ro', isa => SimpleStr, required => TRUE; | |||||||||||
| 27 | |||||||||||||
| 28 | 3 | has 'label_attr' => is => 'ro', isa => SimpleStr, default => NUL; | |||||||||||
| 29 | |||||||||||||
| 30 | 4 | ▶ | has 'resultset_attributes' => is => 'ro', isa => HashRef, builder => sub { {} }; | ||||||||||
|
Subroutine
_build_resultset_attributes: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 31 | |||||||||||||
| 32 | 3 | has 'resultset_class' => is => 'ro', isa => ClassName, | |||||||||||
| 33 | default => 'File::DataClass::ResultSet'; | ||||||||||||
| 34 | |||||||||||||
| 35 | 3 | has 'schema' => is => 'ro', isa => Object, | |||||||||||
| 36 | handles => [ 'path', 'storage' ], | ||||||||||||
| 37 | required => TRUE, weak_ref => TRUE; | ||||||||||||
| 38 | |||||||||||||
| 39 | 3 | ▶ | has 'types' => is => 'ro', isa => HashRef, builder => sub { {} }; | ||||||||||
|
Subroutine
_build_types: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 40 | |||||||||||||
| 41 | 3 | has '_attributes' => is => 'lazy', isa => HashRef, | |||||||||||
| 42 | builder => $_build_attributes, init_arg => undef; | ||||||||||||
| 43 | |||||||||||||
| 44 | # Public methods | ||||||||||||
| 45 | 1 | ▶ | sub columns { | ||||||||||
|
Subroutine
columns: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 46 | 1 | return @{ $_[ 0 ]->attributes }; | |||||||||||
| 47 | } | ||||||||||||
| 48 | |||||||||||||
| 49 | 3 | ▶ | sub has_column { | ||||||||||
|
Subroutine
has_column: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||
| 50 | 3 | ▶ | my $key = $_[ 1 ] // '_invalid_key_'; | ||||||||||
|
Condition100%2/2
$_[1] // "_invalid_key_"
MC/DC100%1/1
$_[1] // "_invalid_key_"
$_[1]
Truth table100%2/2
A
A= $_[1]
| |||||||||||||
| 51 | |||||||||||||
| 52 | 3 | ▶ | return exists $_[ 0 ]->_attributes->{ $key } ? TRUE : FALSE; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 53 | } | ||||||||||||
| 54 | |||||||||||||
| 55 | 20 | ▶ | sub resultset { | ||||||||||
|
Subroutine
resultset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 56 | 20 | my $self = shift; | |||||||||||
| 57 | |||||||||||||
| 58 | 20 | my $attrs = { %{ $self->resultset_attributes }, result_source => $self }; | |||||||||||
| 59 | |||||||||||||
| 60 | 20 | return $self->resultset_class->new( $attrs ); | |||||||||||
| 61 | } | ||||||||||||
| 62 | |||||||||||||
| 63 | 3 | 1; | |||||||||||
| 64 | |||||||||||||
| 65 | __END__ | ||||||||||||