| 1 | package Mojo::Role; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # imports | ||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Mojo::Base -strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use Role::Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Role::Tiny::With (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Mojo::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | # version | ||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.999'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 5 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||
| 13 | # caller is a consumer, import with | ||||||||||||||||||||||||||||
| 14 | # it is assumed that the caller's Mojo::Base imported strict already | ||||||||||||||||||||||||||||
| 15 | 5 | ▶ | if (@_ > 1 and $_[1] eq '-with') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 1 and $_[1] eq "-with"
MC/DC50%1/2
@_ > 1 and $_[1] eq "-with"
@_ > 1
$_[1] eq "-with"
Truth table66%2/3
A and B
A= @_ > 1B= $_[1] eq "-with"
| |||||||||||||||||||||||||||||
| 16 | 1 | @_ = 'Role::Tiny::With'; | |||||||||||||||||||||||||||
| 17 | 1 | goto &Role::Tiny::With::import; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | # the caller is a role | ||||||||||||||||||||||||||||
| 21 | # roles are strict | ||||||||||||||||||||||||||||
| 22 | 4 | Mojo::Base->import('-strict'); | |||||||||||||||||||||||||||
| 23 | 4 | my $target = caller; | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | Mojo::Util::monkey_patch $target, has => sub { Mojo::Base::attr($target, @_) }; | ||||||||||||||||||||||||||
|
Subroutine
has: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | @_ = 'Role::Tiny'; | |||||||||||||||||||||||||||
| 27 | 4 | goto &Role::Tiny::import; | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | 1; | |||||||||||||||||||||||||||
| 31 | __END__ | ||||||||||||||||||||||||||||