« lib/Pod/Coverage/More/Declared/ObjectPad.pm
↑ Summary
blib/lib/Dist/Zilla/Plugin/Test/Pod/Coverage/More.pm »
| 1 | # ABSTRACT: Declarations of the attributes of Class::Tiny classes | ||||||||||||||||||||||||||||
| 2 | # PODNAME: Pod::Coverage::More::Declared::ClassTiny | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | package Pod::Coverage::More::Declared::ClassTiny 0.003; | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 13 | ▶ | use 5.036; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 13 | ▶ | use warnings FATAL => q{all}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 13 | ▶ | use Pod::Coverage::More::Declared; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 13 | ▶ | use Types::Standard qw{InstanceOf}; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | # Whether L<Class::Tiny> built C<package>. | ||||||||||||||||||||||||||||
| 15 | # @param package Str the name of the package | ||||||||||||||||||||||||||||
| 16 | # @returns Bool | ||||||||||||||||||||||||||||
| 17 | # @example next if !Pod::Coverage::More::Declared::ClassTiny->applies_to('Some::Class'); | ||||||||||||||||||||||||||||
| 18 | 42 | ▶ | sub applies_to { | ||||||||||||||||||||||||||
|
Subroutine
applies_to: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 42 | my ( $class, $package ) = @_; | |||||||||||||||||||||||||||
| 20 | 42 | ▶ | return ( $INC{'Class/Tiny.pm'} && $package->isa('Class::Tiny::Object') ) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$INC{"Class/Tiny.pm"} and $package->isa("Class::Tiny::Object")
MC/DC100%2/2
$INC{"Class/Tiny.pm"} and $package->isa("Class::Tiny::Object")
$INC{"Class/Tiny.pm"}
$package->isa("Class::Tiny::Object")
Truth table100%3/3
A and B
A= $INC{"Class/Tiny.pm"}B= $package->isa("Class::Tiny::Object")
| |||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | # The declarations of the subs of C<package> that C<names> lists, as L<Pod::Coverage::More::Declared> describes them. | ||||||||||||||||||||||||||||
| 24 | # @param package Str the name of the package | ||||||||||||||||||||||||||||
| 25 | # @param names ArrayRef[Str] the names of the subs | ||||||||||||||||||||||||||||
| 26 | # @returns HashRef from the name of each declared sub to its declaration | ||||||||||||||||||||||||||||
| 27 | # @example my $declared = Pod::Coverage::More::Declared::ClassTiny->declarations( 'Some::Class', ['new'] ); | ||||||||||||||||||||||||||||
| 28 | 1 | ▶ | sub declarations { | ||||||||||||||||||||||||||
|
Subroutine
declarations: called CC=4 SCAR=14.5
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 1 | my ( $class, $package, $names ) = @_; | |||||||||||||||||||||||||||
| 30 | 1 | my %own = map { $_ => 1 } @$names; | |||||||||||||||||||||||||||
| 31 | 1 | my @attributes = Class::Tiny->get_all_attributes_for($package); | |||||||||||||||||||||||||||
| 32 | 1 | my %declared; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 1 | foreach my $attribute (@attributes) { | |||||||||||||||||||||||||||
| 35 | 2 | ▶ | next if !$own{$attribute}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 2 | $declared{$attribute} = { | |||||||||||||||||||||||||||
| 37 | via => 'Class::Tiny', | ||||||||||||||||||||||||||||
| 38 | role => 'accessor', | ||||||||||||||||||||||||||||
| 39 | attribute => $attribute, | ||||||||||||||||||||||||||||
| 40 | params => [ | ||||||||||||||||||||||||||||
| 41 | Pod::Coverage::More::Declared->invocant, | ||||||||||||||||||||||||||||
| 42 | { name => undef, index => 1, type => undef, optional => 1, invocant => 0 }, | ||||||||||||||||||||||||||||
| 43 | ], | ||||||||||||||||||||||||||||
| 44 | returns => [], | ||||||||||||||||||||||||||||
| 45 | }; | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if ( $own{new} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | $declared{new} = { | ||||||||||||||||||||||||||||
| 49 | via => 'Class::Tiny', | ||||||||||||||||||||||||||||
| 50 | role => 'constructor', | ||||||||||||||||||||||||||||
| 51 | params => [ | ||||||||||||||||||||||||||||
| 52 | Pod::Coverage::More::Declared->invocant, | ||||||||||||||||||||||||||||
| 53 | 0 | map { { name => undef, named => $_, type => undef, optional => 1, invocant => 0 } } @attributes, | |||||||||||||||||||||||||||
| 54 | ], | ||||||||||||||||||||||||||||
| 55 | returns => [ InstanceOf [$package] ], | ||||||||||||||||||||||||||||
| 56 | }; | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 1 | return \%declared; | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 13 | 1; | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||