MooX/SugarFactory.pm

filter: Statementstmt 100% 37 / 37 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 92.3% 48 / 52 CC 3 SCAR 2.9
CC
3
Cov
95%
__ANON__
2.0
import
2.0
__ANON__
1.0
CRAP 1.3
« MooX/BuildClass/Utils.pm ↑ Summary Constructor/SugarLibrary.pm »
1 package MooX::SugarFactory;
2  
3 4 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use MooX::BuildClass;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use MooX::BuildRole;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use Constructor::SugarLibrary ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Throwable::SugarFactory::Utils '_getglob';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 4 our $VERSION = '0.213360'; # VERSION
11  
12 # ABSTRACT: build a library of syntax-sugared Moo classes
13  
14 #
15 # This file is part of Throwable-SugarFactory
16 #
17 #
18 # Christian Walde has dedicated the work to the Commons by waiving all of his
19 # or her rights to the work worldwide under copyright law and all related or
20 # neighboring legal rights he or she had in the work, to the extent allowable by
21 # law.
22 #
23 # Works under CC0 do not require attribution. When citing the work, you should
24 # not imply endorsement by the author.
25 #
26  
27  
28 2 ▶sub import {
Subroutine import: called CC=2 SCAR=6.9
29 2 my ( $class ) = @_;
30 2 Constructor::SugarLibrary->import::into( scalar caller ); # I::I 1.001000
31 2 my $factory = caller;
32 4 *{ _getglob $factory, $_ } = $class->_creator_with( $factory, $_ )
33 2 for qw( class role );
34 }
35  
36 4 ▶sub _creator_with {
Subroutine _creator_with: called CC=1 SCAR=0.0
37 4 my ( $class, $factory, $type ) = @_;
38  
39 # put MooX::Build<Class|Role>'s Build<> into sub <target>::<class|role>
40 # haarg says this working is a perl bug that ignores strict 'refs'
41 4 my $create = \&{ "Build" . ucfirst $type };
42 7 ▶ sub {
Subroutine __ANON__: called CC=2 SCAR=7.1
43 7 my ( $spec, @args ) = @_;
44 7 my ( $class ) = split /->/, $spec;
45  
46 # BUILDARGS can be defined in the factory and munges all class/role's
47 # args, unsure what to do about this yet, need to ask haarg
48 7 ▶ my $build = $factory->can( "BUILDARGS" ) || sub { shift; @_ };
Subroutine __ANON__: called CC=1 SCAR=0.4
Condition33%1/3
$factory->can('BUILDARGS') || sub { shift(); @_; }
l!l&&r!l&&!r
070
MC/DC0%0/2
$factory->can('BUILDARGS') || sub { shift(); @_; }
$factory->can('BUILDARGS') sub { shift(); @_; }
Truth table33%1/3
A || B
A= $factory->can('BUILDARGS')B= sub { shift(); @_; }
ABresult
1X1
011
000
49 7 $create->( $class, $build->( $class, @args ) );
50 7 $factory->sweeten_meth( $spec );
51 7 return;
52 4 };
53 }
54  
55 4 1;
56  
57 __END__
« MooX/BuildClass/Utils.pm ↑ Summary Constructor/SugarLibrary.pm »