| 1 | # ABSTRACT: Declarations of the classes of Object::Pad | ||||||||||||||||||||||||||||
| 2 | # PODNAME: Pod::Coverage::More::Declared::ObjectPad | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Pod::Coverage::More::Declared::ObjectPad 0.001; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 9 | ▶ | use 5.036; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use warnings FATAL => q{all}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use Pod::Coverage::More::Declared; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use Types::Standard qw{InstanceOf}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Whether L<Object::Pad> built C<package>. | ||||||||||||||||||||||||||||
| 15 | # @param package Str the name of the package | ||||||||||||||||||||||||||||
| 16 | # @returns Bool | ||||||||||||||||||||||||||||
| 17 | # @example next if !Pod::Coverage::More::Declared::ObjectPad->applies_to('Some::Class'); | ||||||||||||||||||||||||||||
| 18 | 37 | ▶ | sub applies_to { | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 37 | my ( $class, $package ) = @_; | |||||||||||||||||||||||||||
| 20 | 37 | ▶ | return _metaclass($package) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 38 | ▶ | sub _metaclass { | ||||||||||||||||||||||||||
|
Subroutine
_metaclass: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 38 | my ($package) = @_; | |||||||||||||||||||||||||||
| 25 | 38 | ▶ | return if !$INC{'Object/Pad.pm'}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # The metaclass API warns that it is experimental, and fatal warnings would make that a death. | ||||||||||||||||||||||||||||
| 28 | 9 | ▶ | no warnings q{experimental}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 4 | return eval { Object::Pad::MOP::Class->for_class($package) }; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | # The declarations of the subs of C<package> that C<names> lists, as L<Pod::Coverage::More::Declared> describes them. | ||||||||||||||||||||||||||||
| 33 | # @param package Str the name of the package | ||||||||||||||||||||||||||||
| 34 | # @param names ArrayRef[Str] the names of the subs | ||||||||||||||||||||||||||||
| 35 | # @returns HashRef from the name of each declared sub to its declaration | ||||||||||||||||||||||||||||
| 36 | # @example my $declared = Pod::Coverage::More::Declared::ObjectPad->declarations( 'Some::Class', ['new'] ); | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub declarations { | ||||||||||||||||||||||||||
|
Subroutine
declarations: called CC=7 SCAR=19.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 1 | my ( $class, $package, $names ) = @_; | |||||||||||||||||||||||||||
| 39 | 1 | my $meta = _metaclass($package); | |||||||||||||||||||||||||||
| 40 | 1 | my %own = map { $_ => 1 } @$names; | |||||||||||||||||||||||||||
| 41 | 1 | my %declared; | |||||||||||||||||||||||||||
| 42 | my @named; | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 9 | ▶ | no warnings q{experimental}; # as in _metaclass | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 45 | 1 | foreach my $method ( $meta->direct_methods ) { | |||||||||||||||||||||||||||
| 46 | 2 | ▶ | next if !$own{ $method->name }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 2 | $declared{ $method->name } = { via => 'Object::Pad', role => 'method', params => [ _self() ], returns => [] }; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 1 | foreach my $field ( $meta->fields ) { | |||||||||||||||||||||||||||
| 50 | 1 | my $param = $field->get_attribute_value('param'); | |||||||||||||||||||||||||||
| 51 | 1 | ▶ | push @named, { name => $field->name, named => $param, type => undef, optional => undef, invocant => 0 } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | if defined $param; | ||||||||||||||||||||||||||||
| 53 | 1 | my $reader = $field->get_attribute_value('reader'); | |||||||||||||||||||||||||||
| 54 | $declared{$reader} = { via => 'Object::Pad', role => 'reader', attribute => $field->name, params => [ _self() ], returns => [] } | ||||||||||||||||||||||||||||
| 55 | 1 | ▶ | if defined $reader && $own{$reader}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $reader and $own{$reader}
MC/DC0%0/2
defined $reader and $own{$reader}
defined $reader
$own{$reader}
Truth table33%1/3
A and B
A= defined $readerB= $own{$reader}
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | $declared{new} = { | ||||||||||||||||||||||||||||
| 58 | 1 | via => 'Object::Pad', | |||||||||||||||||||||||||||
| 59 | role => 'constructor', | ||||||||||||||||||||||||||||
| 60 | params => [ Pod::Coverage::More::Declared->invocant, @named ], | ||||||||||||||||||||||||||||
| 61 | returns => [ InstanceOf [$package] ], | ||||||||||||||||||||||||||||
| 62 | }; | ||||||||||||||||||||||||||||
| 63 | 1 | return \%declared; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 3 | ▶ | sub _self { | ||||||||||||||||||||||||||
|
Subroutine
_self: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 3 | return Pod::Coverage::More::Declared->invocant(q{$self}); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 9 | 1; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | __END__ | ||||||||||||||||||||||||||||