| 1 | package Kelp::Module; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 43 | ▶ | use Kelp::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 43 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 43 | our @CARP_NOT = qw(Kelp); | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | attr -app => sub { die "app is required" }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub new | ||||||||||||||||||||||||||||
| 11 | 219 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 219 | my $self = shift->SUPER::new(@_); | |||||||||||||||||||||||||||
| 13 | 219 | $self->app; | |||||||||||||||||||||||||||
| 14 | 218 | return $self; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | # Override this to register items | ||||||||||||||||||||||||||||
| 18 | sub build | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
build: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | 0 | my ($self, %args) = @_; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | sub register | ||||||||||||||||||||||||||||
| 24 | 264 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
register: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 25 | 264 | my ($self, %items) = @_; | |||||||||||||||||||||||||||
| 26 | 264 | ▶ | while (my ($name, $item) = each(%items)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 43 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 43 | ▶ | no warnings 'redefine'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 381 | my $app = ref $self->app; | |||||||||||||||||||||||||||
| 31 | 381 | my $glob = "${app}::$name"; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | # Manually check if the glob is being redefined | ||||||||||||||||||||||||||||
| 34 | 381 | ▶ | if (!$ENV{KELP_REDEFINE} && $self->app->can($name)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $ENV{"KELP_REDEFINE"} and $self->app->can($name)
MC/DC100%2/2
not $ENV{"KELP_REDEFINE"} and $self->app->can($name)
not $ENV{"KELP_REDEFINE"}
$self->app->can($name)
Truth table100%3/3
not(A) and B
A= not $ENV{"KELP_REDEFINE"}B= $self->app->can($name)
| |||||||||||||||||||||||||||||
| 35 | 17 | croak "Redefining of $glob not allowed"; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 364 | ▶ | if (ref $item eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | 180 | *{$glob} = $item; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | else { | ||||||||||||||||||||||||||||
| 42 | 184 | $self->app->{$name} = $item; | |||||||||||||||||||||||||||
| 43 | 184 | ▶ | *{$glob} = sub { $_[0]->{$name} } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | 184 | } | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 43 | 1; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | __END__ | ||||||||||||||||||||||||||||