blib/lib/Class/MOP/Method/Meta.pm

filter: Statementstmt 90.4% 38 / 42 Branchbran 75.0% 6 / 8 Conditioncond 66.6% 4 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 91.6% 11 / 12 Podpod 100% 1 / 1 totaltotal 82.1% 60 / 73 CC 7 SCAR 6.2
CC
7
Cov
86%
wrap
3.0
_make_compatible_with
2.1
BEGIN
2.0
CRAP 1.9
« blib/lib/Moose/Meta/Role/Application.pm ↑ Summary blib/lib/Moose/Exception/MethodNameConflictInRoles.pm »
1 package Class::MOP::Method::Meta;
2 459 our $VERSION = '2.4001';
3  
4 459 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 459 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 459 ▶use Carp 'confess';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 459 ▶use Scalar::Util 'blessed', 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 459 ▶use constant DEBUG_NO_META => $ENV{DEBUG_NO_META} ? 1 : 0;
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'DEBUG_NO_META'} ? : 0 459 459
11  
12 459 ▶use parent 'Class::MOP::Method';
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 0 ▶sub _is_caller_mop_internal {
Subroutine _is_caller_mop_internal: not called CC=1 SCAR=6.9
15 0 my $self = shift;
16 0 my ($caller) = @_;
17 0 return $caller =~ /^(?:Class::MOP|metaclass)(?:::|$)/;
18 }
19  
20 13141 ▶sub _generate_meta_method {
Subroutine _generate_meta_method: called CC=1 SCAR=0.0
21 13141 my $method_self = shift;
22 13141 my $metaclass = shift;
23 13141 weaken($metaclass);
24  
25 85562 ▶ sub {
Subroutine meta: called CC=2 SCAR=7.1
Subroutine __ANON__: called CC=2 SCAR=7.1
26 # this will be compiled out if the env var wasn't set
27 85562 if (DEBUG_NO_META) {
28 confess "'meta' method called by MOP internals"
29 # it's okay to call meta methods on metaclasses, since we
30 # explicitly ask for them
31 if !$_[0]->isa('Class::MOP::Object')
32 && !$_[0]->isa('Class::MOP::Mixin')
33 # it's okay if the test itself calls ->meta, we only care about
34 # if the mop internals call ->meta
35 && $method_self->_is_caller_mop_internal(scalar caller);
36 }
37 # we must re-initialize so that it
38 # works as expected in subclasses,
39 # since metaclass instances are
40 # singletons, this is not really a
41 # big deal anyway.
42 85562 ▶ $metaclass->initialize(blessed($_[0]) || $_[0])
Condition66%4/6
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
35182503800
builtin::blessed($_[0]) || $_[0]
l!l&&r!l&&!r
117517090
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
MC/DC0%0/2
builtin::blessed($_[0]) || $_[0]
builtin::blessed($_[0]) $_[0]
Truth table66%2/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
Truth table66%2/3
A || B
A= builtin::blessed($_[0])B= $_[0]
ABresult
1X1
011
000
43 13141 };
44 }
45  
46 13142 ▶sub wrap {
Subroutine wrap: called CC=3 SCAR=11.0
Pod documented
47 13142 my ($class, @args) = @_;
48  
49 13142 ▶ unshift @args, 'body' if @args % 2 == 1;
Branch: 1 branch
BranchTrueFalseTotal
if @args % 2 == 1 1 13141 13142
50 13142 my %params = @args;
51 $class->_throw_exception( CannotOverrideBodyOfMetaMethods => params => \%params,
52 class => $class
53 )
54 13142 ▶ if $params{body};
Branch: 1 branch
BranchTrueFalseTotal
if $params{"body"} 1 13141 13142
55  
56 13141 my $metaclass_class = $params{associated_metaclass}->meta;
57 13141 $params{body} = $class->_generate_meta_method($metaclass_class);
58 13141 return $class->SUPER::wrap(%params);
59 }
60  
61 128 ▶sub _make_compatible_with {
Subroutine _make_compatible_with: called CC=2 SCAR=7.6
62 128 my $self = shift;
63 128 my ($other) = @_;
64  
65 # XXX: this is pretty gross. the issue here is that CMOP::Method::Meta
66 # objects are subclasses of CMOP::Method, but when we get to moose, they'll
67 # need to be compatible with Moose::Meta::Method, which isn't possible. the
68 # right solution here is to make ::Meta into a role that gets applied to
69 # whatever the method_metaclass happens to be and get rid of
70 # _meta_method_metaclass entirely, but that's not going to happen until
71 # we ditch cmop and get roles into the bootstrapping, so. i'm not
72 # maintaining the previous behavior of turning them into instances of the
73 # new method_metaclass because that's equally broken, and at least this way
74 # any issues will at least be detectable and potentially fixable. -doy
75 128 ▶ return $self unless $other->_is_compatible_with($self->_real_ref_name);
Branch: 1 branch
BranchTrueFalseTotal
unless $other->_is_compatible_with($self->_real_ref_name) 128 0 128
76  
77 0 return $self->SUPER::_make_compatible_with(@_);
78 }
79  
80 459 1;
81  
82 # ABSTRACT: Method Meta Object for C<meta> methods
83  
84 __END__
« blib/lib/Moose/Meta/Role/Application.pm ↑ Summary blib/lib/Moose/Exception/MethodNameConflictInRoles.pm »