line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::SugarFactory; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
81502
|
use strictures 2; |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
87
|
|
4
|
2
|
|
|
2
|
|
898
|
use Import::Into; |
|
2
|
|
|
|
|
2933
|
|
|
2
|
|
|
|
|
53
|
|
5
|
2
|
|
|
2
|
|
868
|
use MooX::BuildClass; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
13
|
|
6
|
2
|
|
|
2
|
|
849
|
use MooX::BuildRole; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
14
|
|
7
|
2
|
|
|
2
|
|
1085
|
use Constructor::SugarLibrary (); |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
54
|
|
8
|
2
|
|
|
2
|
|
14
|
use Throwable::SugarFactory::Utils '_getglob'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
628
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub import { |
29
|
2
|
|
|
2
|
|
193
|
my ( $class ) = @_; |
30
|
2
|
|
|
|
|
19
|
Constructor::SugarLibrary->import::into( scalar caller ); # I::I 1.001000 |
31
|
2
|
|
|
|
|
16
|
my $factory = caller; |
32
|
4
|
|
|
|
|
11
|
*{ _getglob $factory, $_ } = $class->_creator_with( $factory, $_ ) |
33
|
2
|
|
|
|
|
8
|
for qw( class role ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _creator_with { |
37
|
4
|
|
|
4
|
|
11
|
my ( $class, $factory, $type ) = @_; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# put MooX::Build's Build<> into sub :: |
40
|
|
|
|
|
|
|
# haarg says this working is a perl bug that ignores strict 'refs' |
41
|
4
|
|
|
|
|
7
|
my $create = \&{ "Build" . ucfirst $type }; |
|
4
|
|
|
|
|
16
|
|
42
|
|
|
|
|
|
|
sub { |
43
|
7
|
|
|
7
|
|
39
|
my ( $spec, @args ) = @_; |
44
|
7
|
|
|
|
|
25
|
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
|
|
50
|
7
|
|
72
|
my $build = $factory->can( "BUILDARGS" ) || sub { shift; @_ }; |
|
7
|
|
|
|
|
9
|
|
|
7
|
|
|
|
|
38
|
|
49
|
7
|
|
|
|
|
24
|
$create->( $class, $build->( $class, @args ) ); |
50
|
7
|
|
|
|
|
108
|
$factory->sweeten_meth( $spec ); |
51
|
7
|
|
|
|
|
36
|
return; |
52
|
4
|
|
|
|
|
17
|
}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
__END__ |