blib/lib/Moose/Object.pm

filter: Statementstmt 94.1% 81 / 86 Branchbran 87.5% 21 / 24 Conditioncond 86.6% 13 / 15 MC/DCmcdc 60.0% 6 / 10 Subroutinesub 90.9% 20 / 22 Podpod 71.4% 5 / 7 totaltotal 89.0% 146 / 164 CC 20 SCAR 11.5
CC
20
Cov
92%
dump
6.0
does
5.0
BUILDARGS
5.0
CRAP 3.2
« blib/lib/Class/MOP/Method/Constructor.pm ↑ Summary blib/lib/Moose/Meta/TypeConstraint/Enum.pm »
1 package Moose::Object;
2 387 our $VERSION = '2.4001';
3  
4 387 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 387 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 387 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 387 ▶use Devel::GlobalDestruction ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 387 ▶use MRO::Compat ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 387 ▶use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 387 ▶use Try::Tiny ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 387 ▶use Moose::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 387 ▶use if ( not our $__mx_is_compiled ), 'Moose::Meta::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 387 ▶use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 3450 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
Pod documented
19 3450 my $class = shift;
20 3450 ▶ my $real_class = Scalar::Util::blessed($class) || $class;
Condition66%2/3
builtin::blessed($class) || $class
l!l&&r!l&&!r
234480
MC/DC0%0/2
builtin::blessed($class) || $class
builtin::blessed($class) $class
Truth table66%2/3
A || B
A= builtin::blessed($class)B= $class
ABresult
1X1
011
000
21  
22 3450 my $params = $real_class->BUILDARGS(@_);
23  
24 3447 return Class::MOP::Class->initialize($real_class)->new_object($params);
25 }
26  
27 3440 ▶sub BUILDARGS {
Subroutine BUILDARGS: called CC=5 SCAR=16.1
Pod documented
28 3440 my $class = shift;
29 3440 ▶ if ( scalar @_ == 1 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (scalar @_ == 1) { } 15 3425 3440
elsif (@_ % 2) { } 2 3423 3425
30 15 ▶ unless ( defined $_[0] && ref $_[0] eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_[0] and ref $_[0] eq "HASH") 3 12 15
Condition100%3/3
defined $_[0] and ref $_[0] eq "HASH"
!ll&&!rl&&r
1212
MC/DC100%2/2
defined $_[0] and ref $_[0] eq "HASH"
defined $_[0] ref $_[0] eq "HASH"
Truth table100%3/3
A and B
A= defined $_[0]B= ref $_[0] eq "HASH"
ABresult
0X0
100
111
31 3 Moose::Util::throw_exception( "SingleParamsToNewMustBeHashRef" );
32 }
33 12 return { %{ $_[0] } };
34 }
35 elsif ( @_ % 2 ) {
36 2 Carp::carp(
37 "The new() method for $class expects a hash reference or a key/value list."
38 . " You passed an odd number of arguments" );
39 2 return { @_, undef };
40 }
41 else {
42 3423 return { @_ };
43 }
44 }
45  
46 2463 ▶sub BUILDALL {
Subroutine BUILDALL: called CC=4 SCAR=13.9
Pod undocumented
47 # NOTE: we ask Perl if we even
48 # need to do this first, to avoid
49 # extra meta level calls
50 2463 ▶ return unless $_[0]->can('BUILD');
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0]->can("BUILD") 2430 33 2463
51 33 my ($self, $params) = @_;
52 33 ▶ return if $params->{__no_BUILD__};
Branch: 1 branch
BranchTrueFalseTotal
if $params->{"__no_BUILD__"} 2 31 33
53 31 foreach my $method (reverse Class::MOP::class_of($self)->find_all_methods_by_name('BUILD')) {
54 31 $method->{code}->execute($self, $params);
55 }
56 }
57  
58 3430 ▶sub DEMOLISHALL {
Subroutine DEMOLISHALL: called CC=5 SCAR=16.1
Pod undocumented
59 3430 my $self = shift;
60 3430 my ($in_global_destruction) = @_;
61  
62 # NOTE: we ask Perl if we even
63 # need to do this first, to avoid
64 # extra meta level calls
65 3430 ▶ return unless $self->can('DEMOLISH');
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can("DEMOLISH") 3374 56 3430
66  
67 56 my @isa;
68 56 ▶ if ( my $meta = Class::MOP::class_of($self ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $meta = Class::MOP::class_of($self)) { } 55 1 56
69 55 @isa = $meta->linearized_isa;
70 } else {
71 # We cannot count on being able to retrieve a previously made
72 # metaclass, _or_ being able to make a new one during global
73 # destruction. However, we should still be able to use mro at
74 # that time (at least tests suggest so ;)
75 1 my $class_name = ref $self;
76 1 @isa = @{ mro::get_linear_isa($class_name) }
77 }
78  
79 56 foreach my $class (@isa) {
80 387 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
81 119 my $demolish = *{"${class}::DEMOLISH"}{CODE};
82 119 ▶ $self->$demolish($in_global_destruction)
Branch: 1 branch
BranchTrueFalseTotal
if defined $demolish 61 58 119
83 if defined $demolish;
84 }
85 }
86  
87 3430 ▶sub DESTROY {
Subroutine DESTROY: called CC=1 SCAR=0.0
88 3430 my $self = shift;
89  
90 3430 local $?;
91  
92 # < doy> if the destructor is being called because an exception is thrown, then $@ will be set
93 # < doy> but if DEMOLISH does an eval which succeeds, that will clear $@
94 # < doy> which is broken
95 # < doy> try::tiny implicitly localizes $@ in the try block, which fixes that
96 3430 ▶ Try::Tiny::try {
Subroutine __ANON__: called CC=1 SCAR=0.0
97 3430 $self->DEMOLISHALL(Devel::GlobalDestruction::in_global_destruction);
98 }
99 0 ▶ Try::Tiny::catch {
Subroutine __ANON__: not called CC=1 SCAR=6.9
100 0 die $_;
101 3430 };
102  
103 3430 return;
104 }
105  
106 # support for UNIVERSAL::DOES ...
107 387 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.0
108 387 ▶ my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa";
Branch: 1 branch
BranchTrueFalseTotal
'UNIVERSAL'->can('DOES') ? : 387 0 387
109 387 ▶ eval 'sub DOES {
Subroutine DOES: called CC=2 SCAR=6.9
Pod documented
Condition100%3/3
$self->SUPER::DOES($class_or_role_name) || $self->does($class_or_role_name)
l!l&&r!l&&!r
13224
MC/DC100%2/2
$self->SUPER::DOES($class_or_role_name) || $self->does($class_or_role_name)
$self->SUPER::DOES($class_or_role_name) $self->does($class_or_role_name)
Truth table100%3/3
A || B
A= $self->SUPER::DOES($class_or_role_name)B= $self->does($class_or_role_name)
ABresult
1X1
011
000
110 my ( $self, $class_or_role_name ) = @_;
111 return $self->'.$does.'($class_or_role_name)
112 || $self->does($class_or_role_name);
113 }';
114 }
115  
116 # new does() methods will be created
117 # as appropriate see Moose::Meta::Role
118 543 ▶sub does {
Subroutine does: called CC=5 SCAR=16.1
Pod documented
119 543 my ($self, $role_name) = @_;
120 543 ▶ my $class = Scalar::Util::blessed($self) || $self;
Condition66%2/3
builtin::blessed($self) || $self
l!l&&r!l&&!r
1633800
MC/DC0%0/2
builtin::blessed($self) || $self
builtin::blessed($self) $self
Truth table66%2/3
A || B
A= builtin::blessed($self)B= $self
ABresult
1X1
011
000
121 543 my $meta = Class::MOP::Class->initialize($class);
122 543 ▶ (defined $role_name)
Branch: 1 branch
BranchTrueFalseTotal
defined $role_name or Moose::Util::throw_exception("DoesRequiresRoleName", "class_name", $meta->name) 540 3 543
123 || Moose::Util::throw_exception( DoesRequiresRoleName => class_name => $meta->name );
124 540 ▶ return 1 if $meta->can('does_role') && $meta->does_role($role_name);
Branch: 1 branch
BranchTrueFalseTotal
if $meta->can("does_role") and $meta->does_role($role_name) 212 328 540
Condition100%3/3
$meta->can("does_role") and $meta->does_role($role_name)
!ll&&!rl&&r
210118212
MC/DC100%2/2
$meta->can("does_role") and $meta->does_role($role_name)
$meta->can("does_role") $meta->does_role($role_name)
Truth table100%3/3
A and B
A= $meta->can("does_role")B= $meta->does_role($role_name)
ABresult
0X0
100
111
125 328 return 0;
126 }
127  
128 0 ▶sub dump {
Subroutine dump: not called CC=2 SCAR=17.9
Pod documented
129 0 my $self = shift;
130 0 require Data::Dumper;
131 0 ▶ local $Data::Dumper::Maxdepth = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
132 0 Data::Dumper::Dumper $self;
133 }
134  
135 387 1;
136  
137 # ABSTRACT: The base object for Moose
138  
139 __END__
« blib/lib/Class/MOP/Method/Constructor.pm ↑ Summary blib/lib/Moose/Meta/TypeConstraint/Enum.pm »