| 1 | package MooseX::ShortCut::BuildInstance; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | our $AUTHORITY = 'cpan:JANDREW'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use version 0.77; our $VERSION = version->declare('v1.44.2'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | #~ use lib '../../../../Log-Shiras/lib'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | #~ use Log::Shiras::Unhide qw( :InternalBuilDInstancE ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ###InternalBuilDInstancE warn "You uncovered internal logging statements for MooseX::ShortCut::BuildInstance-$VERSION"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Moose 2.1213; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Moose::Meta::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use MooseX::Types::Moose qw( Bool HashRef ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Carp qw( cluck confess ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Moose::Util qw( apply_all_roles ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Moose::Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | Moose::Exporter->setup_import_methods( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | as_is => [qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | build_instance build_class should_re_use_classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | set_class_immutability set_args_cloning | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | )], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Clone 'clone'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | ▶ | use lib '../../../lib',; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use MooseX::ShortCut::BuildInstance::Types 1.036 qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | BuildClassDict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | #########1 Package Variables 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 1 | our $anonymous_class_count = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | our $built_classes = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 1 | our $re_use_classes = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | our $make_classes_immutable = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 1 | our $should_clone_args = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | my @init_class_args = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | superclasses | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | roles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my @add_class_args = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | add_roles_in_sequence | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | add_attributes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | add_methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | #########1 Public Methods 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 7 | ▶ | sub build_class{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_class: called CC=26 SCAR=33.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 7 | ▶ | my $temp_args = ( ( scalar( @_ ) == 1 ) ? $_[0] : { @_ } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 7 | ▶ | my $args = $should_clone_args ? clone( $temp_args ) : $temp_args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | ###InternalBuilDInstancE warn "Arrived at build_class with args:" . Dumper( $args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 7 | my ( $class_args, $i, $can_build, $warning, @warn_list, $pre_exists ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 7 | for my $key ( @init_class_args ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ###InternalBuilDInstancE warn "Processing the class argument: $key"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 21 | ▶ | if( exists $args->{$key} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ###InternalBuilDInstancE warn 'Processing the values:' . Dumper( $args->{$key} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 11 | $class_args->{$key} = $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 11 | ▶ | if( $key eq 'package' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 5 | ▶ | if( $built_classes->{$args->{$key}} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 2 | $pre_exists = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 2 | ▶ | if( !$re_use_classes ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | push @warn_list, 'You already built the class: ' . $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | $warning = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | ###InternalBuilDInstancE warn "unmutablizing the class ..." . Dumper( @warn_list ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | $args->{$key}->meta->make_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 5 | $built_classes->{$args->{$key}} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 11 | delete $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | }elsif( $key eq 'package' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | $class_args->{$key} = "ANONYMOUS_SHIRAS_MOOSE_CLASS_" . ++$anonymous_class_count; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | ###InternalBuilDInstancE warn "missing a package value - using: " . $class_args->{$key}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | }elsif( $key eq 'superclasses' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 2 | $class_args->{$key} = [ 'Anonymous::Shiras::Moose::Class' ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | ###InternalBuilDInstancE warn "missing the superclass value - using: " . Dumper( $class_args->{$key} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 7 | ▶ | if( $warning ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | push @warn_list, 'The old class definitions will be overwritten with args:', Dumper( $class_args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | cluck( join( "\n", @warn_list ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 6 | my $package_key = $class_args->{package}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 6 | $package_key =~ s/::/\//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 6 | $package_key .= '.pm'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 6 | ▶ | if( exists $INC{$package_key} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | if( $re_use_classes ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | ###InternalBuilDInstancE warn "Already built the class: $class_args->{package}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | return $class_args->{package};# Don't rebuild if you are re-using | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | cluck "Overwriting a pre-built and loaded class: " . $class_args->{package} ; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | $class_args->{package}->meta->make_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | my $want_array = ( caller(0) )[5]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | ###InternalBuilDInstancE warn 'class args:' . Dumper( $class_args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | ###InternalBuilDInstancE warn 'remaining arguments:' . Dumper( $args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ###InternalBuilDInstancE warn "want array: $want_array"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ###InternalBuilDInstancE warn "Pre exists state: " . ($pre_exists//''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ###InternalBuilDInstancE warn "\$warning state: " . ($warning//''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ###InternalBuilDInstancE warn 'finalize the class name or load a new one ...'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | my $class_name = ( $pre_exists and !$warning ) ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | $class_args->{package} : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 6 | ▶ | Moose::Meta::Class->create( %{$class_args} )->name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$pre_exists and not $warning
MC/DC0%0/2
$pre_exists and not $warning
$pre_exists
not $warning
Truth table66%2/3
A and not(B)
A= $pre_existsB= not $warning
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | ###InternalBuilDInstancE warn 'class to this point: ' . $class_name->dump( 2 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 6 | ▶ | if( !$class_name->meta->is_mutable and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition11%1/9
not $class_name->meta->is_mutable and exists $args->{"add_attributes"} || exists $args->{"add_methods"} || exists $args->{"add_roles_in_sequence"}
exists $args->{"add_attributes"} or exists $args->{"add_methods"} or exists $args->{"add_roles_in_sequence"}
exists $args->{"add_attributes"} or exists $args->{"add_methods"}
MC/DC0%0/4
not $class_name->meta->is_mutable and exists $args->{"add_attributes"} || exists $args->{"add_methods"} || exists $args->{"add_roles_in_sequence"}
not $class_name->meta->is_mutable
exists $args->{"add_attributes"}
exists $args->{"add_methods"}
exists $args->{"add_roles_in_sequence"}
Truth table20%1/5
not(A) and B or C or D
A= not $class_name->meta->is_mutableB= exists $args->{"add_attributes"}C= exists $args->{"add_methods"}D= exists $args->{"add_roles_in_sequence"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | ( exists $args->{add_attributes} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | exists $args->{add_methods} or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | exists $args->{add_roles_in_sequence} ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ###InternalBuilDInstancE warn 'Un-immutablizing the class ...'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $class_name->meta->make_mutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 6 | ▶ | if( exists $args->{add_attributes} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | ###InternalBuilDInstancE warn "Found attributes to add"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | my $meta = $class_name->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | for my $attribute ( keys %{$args->{add_attributes}} ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | ###InternalBuilDInstancE warn "adding attribute named: $attribute"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 1 | $meta->add_attribute( $attribute => $args->{add_attributes}->{$attribute} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 1 | delete $args->{add_attributes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 6 | ▶ | if( exists $args->{add_methods} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | ###InternalBuilDInstancE warn "Found roles to add"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | my $meta = $class_name->meta; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 4 | for my $method ( keys %{$args->{add_methods}} ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | ###InternalBuilDInstancE warn "adding method named: $method"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | $meta->add_method( $method => $args->{add_methods}->{$method} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 4 | delete $args->{add_methods}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 6 | ▶ | if( exists $args->{add_roles_in_sequence} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | ###InternalBuilDInstancE warn "Found roles_in_sequence to add"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | for my $role ( @{$args->{add_roles_in_sequence}} ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | ###InternalBuilDInstancE warn "adding role:" . Dumper( $role ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 4 | apply_all_roles( $class_name, $role ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 4 | delete $args->{add_roles_in_sequence}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 6 | ▶ | if( $make_classes_immutable ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | ###InternalBuilDInstancE warn 'Immutablizing the class ...'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 6 | $class_name->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | ###InternalBuilDInstancE warn "returning: $class_name"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 6 | return $class_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 3 | ▶ | sub build_instance{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_instance: called CC=9 SCAR=29.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 3 | ▶ | my $temp_args = is_HashRef( $_[0] ) ? $_[0] : { @_ }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 3 | ▶ | my $args = $should_clone_args ? clone( $temp_args ) : $temp_args; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ###InternalBuilDInstancE warn "Arrived at build_instance with args:" . Dumper( $args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 3 | my $class_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | for my $key ( @init_class_args, @add_class_args ){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 18 | ▶ | if( exists $args->{$key} ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 8 | $class_args->{$key} = $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 8 | delete $args->{$key}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | ###InternalBuilDInstancE warn 'Reduced arguments:' . Dumper( $args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | ###InternalBuilDInstancE warn 'Class building arguments:' . Dumper( $class_args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 3 | my $class = build_class( $class_args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | ###InternalBuilDInstancE warn "Built class -$class- To get instance now applying args:" . Dumper( $args ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 3 | my $instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | eval '$instance = $class->new( %$args )'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | ▶ | if( $@ ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | my $message = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if( ref $message ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if( $message->can( 'as_string' ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $message = $message->as_string; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | }elsif( $message->can( 'message' ) ){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $message = $message->message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $message =~ s/\)\n;/\);/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | cluck $message; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | ###InternalBuilDInstancE warn "Built instance:" . Dumper( $instance ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | return $instance; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | sub should_re_use_classes{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
should_re_use_classes: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | my ( $bool, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | ###InternalBuilDInstancE warn "setting \$re_use_classes to: $bool"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1 | ▶ | $re_use_classes = ( $bool ) ? 1 : 0 ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub set_class_immutability{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_class_immutability: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | my ( $bool, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | ###InternalBuilDInstancE warn "setting \$make_immutable_classes to; $bool"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $make_classes_immutable = ( $bool ) ? 1 : 0 ; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub set_args_cloning{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_args_cloning: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | my ( $bool, ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $should_clone_args = !!$bool; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ###InternalBuilDInstancE warn "set \$should_clone_args to; $should_clone_args"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | #########1 Phinish strong 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | #########1 Default class 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | package Anonymous::Shiras::Moose::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | our $AUTHORITY = 'cpan:JANDREW'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 1 | ▶ | no Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # The preceding line will help the module return a true value | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | #########1 main pod docs 3#########4#########5#########6#########7#########8#########9 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||