line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Meta::Builder; |
2
|
2
|
|
|
2
|
|
148338
|
use strict; |
|
2
|
|
|
|
|
12
|
|
|
2
|
|
|
|
|
56
|
|
3
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
43
|
|
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
33
|
use 5.006; |
|
2
|
|
|
|
|
6
|
|
6
|
2
|
|
|
2
|
|
10
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
108
|
|
7
|
2
|
|
|
2
|
|
770
|
use Meta::Builder::Util; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
10
|
|
8
|
2
|
|
|
2
|
|
820
|
use Meta::Builder::Base; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
592
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.004"; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @SUGAR = qw/metric action hash_metric lists_metric/; |
13
|
|
|
|
|
|
|
our @HOOKS = qw/before after/; |
14
|
|
|
|
|
|
|
our @METHODS = (( map { "add_$_" } @SUGAR ), |
15
|
|
|
|
|
|
|
( map { "hook_$_" } @HOOKS )); |
16
|
|
|
|
|
|
|
our @EXPORT = ( @SUGAR, @HOOKS, qw/make_immutable accessor/ ); |
17
|
|
|
|
|
|
|
our @REMOVABLE = ( @EXPORT, @METHODS ); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
for my $item ( @SUGAR ) { |
20
|
|
|
|
|
|
|
my $wraps = "add_$item"; |
21
|
|
|
|
|
|
|
inject( __PACKAGE__, $item, sub { |
22
|
6
|
|
|
6
|
|
116
|
caller->$wraps(@_) |
23
|
|
|
|
|
|
|
}); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
for my $item ( @HOOKS ) { |
27
|
|
|
|
|
|
|
my $wraps = "hook_$item"; |
28
|
|
|
|
|
|
|
inject( __PACKAGE__, $item, sub { |
29
|
0
|
|
|
0
|
|
0
|
caller->$wraps(@_) |
30
|
|
|
|
|
|
|
}); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub import { |
34
|
2
|
|
|
2
|
|
1050
|
my $class = shift; |
35
|
2
|
|
|
|
|
8
|
my $caller = caller; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
55
|
inject( $caller, $_, $class->can( $_ )) for @EXPORT; |
38
|
2
|
|
|
2
|
|
15
|
no strict 'refs'; ## no critic |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
409
|
|
39
|
2
|
|
|
|
|
5
|
push @{"$caller\::ISA"} => 'Meta::Builder::Base'; |
|
2
|
|
|
|
|
1633
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub make_immutable { |
43
|
1
|
|
33
|
1
|
1
|
389
|
my $class = shift || caller; |
44
|
1
|
|
|
|
|
4
|
for my $sub ( @REMOVABLE ) { |
45
|
|
|
|
|
|
|
inject( $class, $sub, sub { |
46
|
14
|
|
|
14
|
|
9287
|
croak "$class has been made immutable, cannot call '$sub'" |
47
|
14
|
|
|
|
|
49
|
}, 1 ); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub accessor { |
52
|
2
|
|
|
2
|
1
|
1353
|
my $class = caller; |
53
|
2
|
|
|
|
|
58
|
$class->set_accessor( @_ ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
__END__ |