| 1 | package Punk::Controller; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 21 | ▶ | use 5.010; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 21 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 21 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 21 | our $VERSION = '0.70'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # `use Punk::Controller;` is the one-line preamble: it makes the caller a | ||||||||||||||||||||||||||||
| 10 | # controller and turns on strict and warnings, which is what `use Punk::Model` | ||||||||||||||||||||||||||||
| 11 | # does for a model and what every controller was writing by hand. The older | ||||||||||||||||||||||||||||
| 12 | # `use parent 'Punk::Controller'` still works and is untouched - it just does | ||||||||||||||||||||||||||||
| 13 | # not carry the pragmas, exactly as before. | ||||||||||||||||||||||||||||
| 14 | 35 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 15 | 35 | my ($class) = @_; | |||||||||||||||||||||||||||
| 16 | 35 | my $caller = caller; | |||||||||||||||||||||||||||
| 17 | # The pragmas are unconditional: they are the reason to write the one-line | ||||||||||||||||||||||||||||
| 18 | # form, and a caller that already inherits (through `use parent`, or a | ||||||||||||||||||||||||||||
| 19 | # second `use`) still wants them. Only the @ISA push is guarded, so it | ||||||||||||||||||||||||||||
| 20 | # cannot be applied twice or to main. | ||||||||||||||||||||||||||||
| 21 | 35 | ▶ | if ( $caller ne 'main' && !$caller->isa($class) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$caller ne "main" and not $caller->isa($class)
MC/DC100%2/2
$caller ne "main" and not $caller->isa($class)
$caller ne "main"
not $caller->isa($class)
Truth table100%3/3
A and not(B)
A= $caller ne "main"B= not $caller->isa($class)
| |||||||||||||||||||||||||||||
| 22 | 21 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 31 | push @{"${caller}::ISA"}, $class; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | # Ordinary method calls, so the hint bits land in the scope being compiled | ||||||||||||||||||||||||||||
| 26 | # - the caller's file - rather than in this one. | ||||||||||||||||||||||||||||
| 27 | 35 | strict->import; | |||||||||||||||||||||||||||
| 28 | 35 | warnings->import; | |||||||||||||||||||||||||||
| 29 | 35 | return; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 21 | 1; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | __END__ | ||||||||||||||||||||||||||||