| 1 | package Class::Easy::Base; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use Class::Easy::Import; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2 | require Class::Easy; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||
| 8 | 1 | my $mypkg = shift; | |||||||||||||||||||||||||||
| 9 | 1 | my $callpkg = caller; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 1 | my %params = @_; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | # use warnings | ||||||||||||||||||||||||||||
| 14 | 1 | ${^WARNING_BITS} ^= ${^WARNING_BITS} ^ $Class::Easy::Import::WARN; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | # use strict, use utf8; | ||||||||||||||||||||||||||||
| 17 | 1 | $^H |= $Class::Easy::Import::H; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | # use feature | ||||||||||||||||||||||||||||
| 20 | 1 | $^H{feature_switch} = $^H{feature_say} = $^H{feature_state} = 1; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # probably check for try_to_use is enough | ||||||||||||||||||||||||||||
| 23 | return | ||||||||||||||||||||||||||||
| 24 | 1 | if defined *{"$callpkg\::try_to_use"}{CODE} | |||||||||||||||||||||||||||
| 25 | 0 | ▶ | and Class::Easy::sub_fullname (*{"$callpkg\::try_to_use"}{CODE}) eq 'Class::Easy::__ANON__'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined *{"${callpkg}::try_to_use";}{"CODE"} and &Class::Easy::sub_fullname(scalar *{"${callpkg}::try_to_use";}{"CODE"}) eq "Class::Easy::__ANON__"
MC/DC0%0/2
defined *{"${callpkg}::try_to_use";}{"CODE"} and &Class::Easy::sub_fullname(scalar *{"${callpkg}::try_to_use";}{"CODE"}) eq "Class::Easy::__ANON__"
defined *{"${callpkg}::try_to_use";}{"CODE"}
&Class::Easy::sub_fullname(scalar *{"${callpkg}::try_to_use";}{"CODE"}) eq "Class::Easy::__ANON__"
Truth table33%1/3
A and B
A= defined *{"${callpkg}::try_to_use";}{"CODE"}B= &Class::Easy::sub_fullname(scalar *{"${callpkg}::try_to_use";}{"CODE"}) eq "Class::Easy::__ANON__"
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # export subs | ||||||||||||||||||||||||||||
| 28 | 1 | *{"$callpkg\::$_"} = \&{"Class::Easy::$_"} foreach @Class::Easy::EXPORT; | |||||||||||||||||||||||||||
| 29 | 1 | foreach my $p (keys %Class::Easy::EXPORT_FOREIGN) { | |||||||||||||||||||||||||||
| 30 | 1 | *{"$callpkg\::$_"} = \&{"$p\::$_"} foreach @{$Class::Easy::EXPORT_FOREIGN{$p}}; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 1 | push @{"$callpkg\::ISA"}, 'Class::Easy::Base'; | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 39 | 1 | my $params = {@_}; | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 1 | bless $params, $class; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 2 | ▶ | sub set_field_values { | ||||||||||||||||||||||||||
|
Subroutine
set_field_values: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 46 | 2 | my %params = @_; | |||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | foreach my $k (keys %params) { | |||||||||||||||||||||||||||
| 49 | 2 | $self->$k ($params{$k}); | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub list_all_subs { | ||||||||||||||||||||||||||
|
Subroutine
list_all_subs: called CC=3 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 54 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 1 | my $sub_by_type = Class::Easy::list_all_subs_for ($class); | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | wantarray | ||||||||||||||||||||||||||||
| 61 | ? ( | ||||||||||||||||||||||||||||
| 62 | 0 | keys %{$sub_by_type->{method}}, | |||||||||||||||||||||||||||
| 63 | 0 | keys %{$sub_by_type->{runtime}}, | |||||||||||||||||||||||||||
| 64 | 0 | ▶ | map {@{$sub_by_type->{inherited}->{$_}}} keys %{$sub_by_type->{inherited}}) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | : $sub_by_type; | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 1 | ▶ | sub attach_paths { | ||||||||||||||||||||||||||
|
Subroutine
attach_paths: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 70 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | $class = ref $class if ref $class; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | my @pack_chunks = split(/\:\:/, $class); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 1 | require File::Spec; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | my $FS = 'File::Spec'; | |||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | 1 | my $pack_path = join ('/', @pack_chunks) . '.pm'; | |||||||||||||||||||||||||||
| 81 | 1 | my $pack_inc_path = $INC{$pack_path}; | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 1 | $pack_path = $FS->canonpath ($pack_path); | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 1 | my $pack_abs_path = $FS->rel2abs ($FS->canonpath ($pack_inc_path)); | |||||||||||||||||||||||||||
| 86 | 1 | Class::Easy::make_accessor ($class, 'package_path', default => $pack_abs_path); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 1 | my $lib_path = substr ($pack_abs_path, 0, rindex ($pack_abs_path, $pack_path)); | |||||||||||||||||||||||||||
| 89 | 1 | Class::Easy::make_accessor ($class, 'lib_path', default => $FS->canonpath ($lib_path)); | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 2 | 1; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | __END__ | ||||||||||||||||||||||||||||