| 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
MC/DC0%0/2
builtin::blessed($class) || $class
builtin::blessed($class)
$class
Truth table66%2/3
A || B
A= builtin::blessed($class)B= $class
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 30 | 15 | ▶ | unless ( defined $_[0] && ref $_[0] eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $_[0] and ref $_[0] eq "HASH"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 51 | 33 | my ($self, $params) = @_; | |||||||||||||||||||||||||||
| 52 | 33 | ▶ | return if $params->{__no_BUILD__}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 56 | my @isa; | |||||||||||||||||||||||||||
| 68 | 56 | ▶ | if ( my $meta = Class::MOP::class_of($self ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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)
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)
| |||||||||||||||||||||||||||||
| 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
MC/DC0%0/2
builtin::blessed($self) || $self
builtin::blessed($self)
$self
Truth table66%2/3
A || B
A= builtin::blessed($self)B= $self
| |||||||||||||||||||||||||||||
| 121 | 543 | my $meta = Class::MOP::Class->initialize($class); | |||||||||||||||||||||||||||
| 122 | 543 | ▶ | (defined $role_name) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
Condition100%3/3
$meta->can("does_role") and $meta->does_role($role_name)
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)
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 132 | 0 | Data::Dumper::Dumper $self; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 387 | 1; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | # ABSTRACT: The base object for Moose | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | __END__ | ||||||||||||||||||||||||||||