| 1 | package Mouse::Role; | ||||||||||||||||||||||||||||||||||||||
| 2 | 92 | ▶ | use Mouse::Exporter; # enables strict and warnings | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||
| 4 | 92 | ▶ | use version; our $VERSION = version->declare('v2.6.2'); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||
| 6 | 92 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 92 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||
| 9 | 92 | ▶ | use Mouse (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||
| 11 | 32 | Mouse::Exporter->setup_import_methods( | |||||||||||||||||||||||||||||||||||||
| 12 | as_is => [qw( | ||||||||||||||||||||||||||||||||||||||
| 13 | extends with | ||||||||||||||||||||||||||||||||||||||
| 14 | has | ||||||||||||||||||||||||||||||||||||||
| 15 | before after around | ||||||||||||||||||||||||||||||||||||||
| 16 | override super | ||||||||||||||||||||||||||||||||||||||
| 17 | augment inner | ||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||
| 19 | requires excludes | ||||||||||||||||||||||||||||||||||||||
| 20 | ), | ||||||||||||||||||||||||||||||||||||||
| 21 | \&Scalar::Util::blessed, | ||||||||||||||||||||||||||||||||||||||
| 22 | \&Carp::confess, | ||||||||||||||||||||||||||||||||||||||
| 23 | ], | ||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||
| 27 | 2 | ▶ | sub extends { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
extends: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 28 | 2 | Carp::croak "Roles do not support 'extends'"; | |||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | 36 | ▶ | sub with { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
with: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 32 | 36 | Mouse::Util::apply_all_roles(scalar(caller), @_); | |||||||||||||||||||||||||||||||||||||
| 33 | 33 | return; | |||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | 59 | ▶ | sub has { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
has: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 37 | 59 | my $meta = Mouse::Meta::Role->initialize(scalar caller); | |||||||||||||||||||||||||||||||||||||
| 38 | 59 | my $name = shift; | |||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||
| 40 | 59 | ▶ | $meta->throw_error(q{Usage: has 'name' => ( key => value, ... )}) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 41 | if @_ % 2; # odd number of arguments | ||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | 59 | ▶ | for my $n(ref($name) ? @{$name} : $name){ | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 44 | 61 | $meta->add_attribute($n => @_); | |||||||||||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||||||||||||
| 46 | 59 | return; | |||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | sub before { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
before: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 50 | 8 | my $meta = Mouse::Meta::Role->initialize(scalar caller); | |||||||||||||||||||||||||||||||||||||
| 51 | 8 | my $code = pop; | |||||||||||||||||||||||||||||||||||||
| 52 | 8 | for my $name($meta->_collect_methods(@_)) { | |||||||||||||||||||||||||||||||||||||
| 53 | 7 | $meta->add_before_method_modifier($name => $code); | |||||||||||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||||||||||||
| 55 | 7 | return; | |||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||
| 58 | 12 | ▶ | sub after { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
after: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 59 | 12 | my $meta = Mouse::Meta::Role->initialize(scalar caller); | |||||||||||||||||||||||||||||||||||||
| 60 | 12 | my $code = pop; | |||||||||||||||||||||||||||||||||||||
| 61 | 12 | for my $name($meta->_collect_methods(@_)) { | |||||||||||||||||||||||||||||||||||||
| 62 | 11 | $meta->add_after_method_modifier($name => $code); | |||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||
| 64 | 11 | return; | |||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||
| 67 | 12 | ▶ | sub around { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
around: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 68 | 12 | my $meta = Mouse::Meta::Role->initialize(scalar caller); | |||||||||||||||||||||||||||||||||||||
| 69 | 12 | my $code = pop; | |||||||||||||||||||||||||||||||||||||
| 70 | 12 | for my $name($meta->_collect_methods(@_)) { | |||||||||||||||||||||||||||||||||||||
| 71 | 12 | $meta->add_around_method_modifier($name => $code); | |||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||
| 73 | 11 | return; | |||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||
| 77 | 12 | ▶ | sub super { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
super: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 78 | 12 | ▶ | return if !defined $Mouse::SUPER_BODY; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 79 | 12 | $Mouse::SUPER_BODY->(@Mouse::SUPER_ARGS); | |||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||
| 82 | 9 | ▶ | sub override { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
override: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 83 | # my($name, $code) = @_; | ||||||||||||||||||||||||||||||||||||||
| 84 | 9 | Mouse::Meta::Role->initialize(scalar caller)->add_override_method_modifier(@_); | |||||||||||||||||||||||||||||||||||||
| 85 | 8 | return; | |||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||
| 88 | # We keep the same errors messages as Moose::Role emits, here. | ||||||||||||||||||||||||||||||||||||||
| 89 | 1 | ▶ | sub inner { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
inner: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 90 | 1 | Carp::croak "Roles cannot support 'inner'"; | |||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||
| 93 | 1 | ▶ | sub augment { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
augment: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 94 | 1 | Carp::croak "Roles cannot support 'augment'"; | |||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | 21 | ▶ | sub requires { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
requires: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 98 | 21 | my $meta = Mouse::Meta::Role->initialize(scalar caller); | |||||||||||||||||||||||||||||||||||||
| 99 | 21 | ▶ | $meta->throw_error("Must specify at least one method") unless @_; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 100 | 21 | $meta->add_required_methods(@_); | |||||||||||||||||||||||||||||||||||||
| 101 | 21 | return; | |||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | sub excludes { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
excludes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||
| 105 | 1 | Mouse::Util::not_supported(); | |||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||
| 108 | 200 | ▶ | sub init_meta{ | ||||||||||||||||||||||||||||||||||||
|
Subroutine
init_meta: called CC=5 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 109 | 200 | shift; | |||||||||||||||||||||||||||||||||||||
| 110 | 200 | my %args = @_; | |||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||
| 112 | my $class = $args{for_class} | ||||||||||||||||||||||||||||||||||||||
| 113 | 200 | ▶ | or Carp::confess("Cannot call init_meta without specifying a for_class"); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||
| 115 | 200 | ▶ | my $metaclass = $args{metaclass} || 'Mouse::Meta::Role'; | ||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'metaclass'} || 'Mouse::Meta::Role'
MC/DC0%0/1
$args{'metaclass'} || 'Mouse::Meta::Role'
$args{'metaclass'}
Truth table50%1/2
A
A= $args{'metaclass'}
| |||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||
| 117 | 200 | my $meta = $metaclass->initialize($class); | |||||||||||||||||||||||||||||||||||||
| 118 | 200 | my $filename = Mouse::Util::module_notional_filename($meta->name); | |||||||||||||||||||||||||||||||||||||
| 119 | $INC{$filename} = '(set by Mouse)' | ||||||||||||||||||||||||||||||||||||||
| 120 | 200 | ▶ | unless exists $INC{$filename}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||
| 122 | 22 | ▶ | $meta->add_method(meta => sub{ | ||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=9.2
Subroutine
meta: called CC=2 SCAR=9.2
| |||||||||||||||||||||||||||||||||||||||
| 123 | 22 | ▶ | $metaclass->initialize(ref($_[0]) || $_[0]); | ||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
ref $_[0] || $_[0]
ref $_[0] || $_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0]
$_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
Truth table33%1/3
A || B
A= ref $_[0]B= $_[0]
| |||||||||||||||||||||||||||||||||||||||
| 124 | 200 | }); | |||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||
| 126 | # make a role type for each Mouse role | ||||||||||||||||||||||||||||||||||||||
| 127 | 200 | ▶ | Mouse::Util::TypeConstraints::role_type($class) | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 128 | unless Mouse::Util::TypeConstraints::find_type_constraint($class); | ||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||
| 130 | 200 | return $meta; | |||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||
| 133 | 32 | 1; | |||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||
| 135 | __END__ | ||||||||||||||||||||||||||||||||||||||