| 1 | package Mojo::RoleTiny; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Mojo::RoleTiny - Tiny and simple role system for Mojo | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | # imports | ||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Mojo::Base -strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use Role::Tiny (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use Role::Tiny::With (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use Mojo::Util (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # version | ||||||||||||||||||||||||||||
| 12 | 1 | our $VERSION = 0.022; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||
| 15 | # caller is a consumer, import with | ||||||||||||||||||||||||||||
| 16 | # it is assumed that the caller's Mojo::Base imported strict already | ||||||||||||||||||||||||||||
| 17 | 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"
| |||||||||||||||||||||||||||||
| 18 | 1 | @_ = 'Role::Tiny::With'; | |||||||||||||||||||||||||||
| 19 | 1 | goto &Role::Tiny::With::import; | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # the caller is a role | ||||||||||||||||||||||||||||
| 23 | # roles are strict | ||||||||||||||||||||||||||||
| 24 | 4 | Mojo::Base->import('-strict'); | |||||||||||||||||||||||||||
| 25 | 4 | my $target = caller; | |||||||||||||||||||||||||||
| 26 | 0 | ▶ | Mojo::Util::monkey_patch $target, has => sub { Mojo::Base::attr($target, @_) }; | ||||||||||||||||||||||||||
|
Subroutine
has: not called CC=1 SCAR=2.6
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 4 | @_ = 'Role::Tiny'; | |||||||||||||||||||||||||||
| 29 | 4 | goto &Role::Tiny::import; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | 1; | |||||||||||||||||||||||||||
| 33 | __END__ | ||||||||||||||||||||||||||||