line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package UR::Role; |
2
|
|
|
|
|
|
|
|
3
|
266
|
|
|
266
|
|
1120
|
use strict; |
|
266
|
|
|
|
|
357
|
|
|
266
|
|
|
|
|
7837
|
|
4
|
266
|
|
|
266
|
|
936
|
use warnings; |
|
266
|
|
|
|
|
318
|
|
|
266
|
|
|
|
|
7727
|
|
5
|
|
|
|
|
|
|
|
6
|
266
|
|
|
266
|
|
890
|
use UR; |
|
266
|
|
|
|
|
304
|
|
|
266
|
|
|
|
|
2325
|
|
7
|
266
|
|
|
266
|
|
937
|
use UR::Object::Type::InternalAPI; |
|
266
|
|
|
|
|
317
|
|
|
266
|
|
|
|
|
3075
|
|
8
|
266
|
|
|
266
|
|
5151
|
use UR::Util; |
|
266
|
|
|
|
|
388
|
|
|
266
|
|
|
|
|
1747
|
|
9
|
266
|
|
|
266
|
|
4561
|
use UR::AttributeHandlers; |
|
266
|
|
|
|
|
364
|
|
|
266
|
|
|
|
|
1330
|
|
10
|
|
|
|
|
|
|
|
11
|
266
|
|
|
266
|
|
86013
|
use UR::Role::Param; |
|
266
|
|
|
|
|
550
|
|
|
266
|
|
|
|
|
2444
|
|
12
|
266
|
|
|
266
|
|
107228
|
use UR::Role::Prototype; |
|
266
|
|
|
|
|
723
|
|
|
266
|
|
|
|
|
2376
|
|
13
|
266
|
|
|
266
|
|
144556
|
use UR::Role::PrototypeWithParams; |
|
266
|
|
|
|
|
494
|
|
|
266
|
|
|
|
|
2494
|
|
14
|
266
|
|
|
266
|
|
85412
|
use UR::Role::Instance; |
|
266
|
|
|
|
|
666
|
|
|
266
|
|
|
|
|
2595
|
|
15
|
|
|
|
|
|
|
|
16
|
266
|
|
|
266
|
|
10154
|
use Scalar::Util qw(blessed); |
|
266
|
|
|
|
|
347
|
|
|
266
|
|
|
|
|
14481
|
|
17
|
266
|
|
|
266
|
|
1027
|
use List::MoreUtils qw(any); |
|
266
|
|
|
|
|
347
|
|
|
266
|
|
|
|
|
2092
|
|
18
|
266
|
|
|
266
|
|
98503
|
use Sub::Install; |
|
266
|
|
|
|
|
372
|
|
|
266
|
|
|
|
|
2418
|
|
19
|
266
|
|
|
266
|
|
6551
|
use Sub::Name; |
|
266
|
|
|
|
|
349
|
|
|
266
|
|
|
|
|
9361
|
|
20
|
266
|
|
|
266
|
|
987
|
use Carp; |
|
266
|
|
|
|
|
321
|
|
|
266
|
|
|
|
|
16054
|
|
21
|
|
|
|
|
|
|
our @CARP_NOT = qw(UR::Object::Type); |
22
|
|
|
|
|
|
|
|
23
|
266
|
|
|
266
|
|
1060
|
use Exporter qw(import); |
|
266
|
|
|
|
|
319
|
|
|
266
|
|
|
|
|
97168
|
|
24
|
|
|
|
|
|
|
our @EXPORT_OK = qw(before after around); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
our $VERSION = "0.46"; # UR $VERSION;; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Class::Autouse->sugar(\&_define_role); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub define { |
31
|
0
|
|
|
0
|
0
|
0
|
my $class = shift; |
32
|
0
|
|
|
|
|
0
|
UR::Role::Prototype->define(@_); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub _define_role { |
36
|
2147
|
|
|
2147
|
|
396124
|
my($role_name, $func, @params) = @_; |
37
|
|
|
|
|
|
|
|
38
|
2147
|
100
|
66
|
|
|
17614
|
if (defined($func) and $func eq "role" and @params > 1 and $role_name ne "UR::Role") { |
|
|
|
66
|
|
|
|
|
|
|
|
66
|
|
|
|
|
39
|
42
|
|
|
|
|
53
|
my @role_params; |
40
|
42
|
50
|
33
|
|
|
225
|
if (@params == 2 and ref($params[1]) eq 'HASH') { |
|
|
0
|
0
|
|
|
|
|
41
|
42
|
|
|
|
|
58
|
@role_params = %{ $params[1] }; |
|
42
|
|
|
|
|
117
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif (@params == 2 and ref($params[1]) eq 'ARRAY') { |
44
|
0
|
|
|
|
|
0
|
@role_params = @{ $params[1] }; |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
0
|
@role_params = @params[1..$#params]; |
48
|
|
|
|
|
|
|
} |
49
|
42
|
|
|
|
|
192
|
my $role = UR::Role::Prototype->define(role_name => $role_name, @role_params); |
50
|
41
|
50
|
|
|
|
116
|
unless ($role) { |
51
|
0
|
|
|
|
|
0
|
Carp::croak "error defining role $role_name!"; |
52
|
|
|
|
|
|
|
} |
53
|
41
|
|
|
41
|
|
205
|
return sub { $role_name }; |
|
41
|
|
|
|
|
231
|
|
54
|
|
|
|
|
|
|
} else { |
55
|
2105
|
|
|
|
|
4979
|
return; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
foreach my $type ( qw(before after around) ) { |
60
|
|
|
|
|
|
|
my $modifier_class = join('::', 'UR::Role::MethodModifier', ucfirst($type)); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $sub = Sub::Name::subname $type => sub { |
63
|
3
|
|
|
3
|
|
21
|
my $subname = shift; |
|
|
|
|
3
|
|
|
|
|
|
|
|
3
|
|
|
|
64
|
3
|
|
|
|
|
6
|
my $code = shift; |
65
|
|
|
|
|
|
|
|
66
|
3
|
|
|
|
|
7
|
my $package = caller; |
67
|
3
|
|
|
|
|
56
|
my $b = $modifier_class->create( |
68
|
|
|
|
|
|
|
role_name => $package, |
69
|
|
|
|
|
|
|
name => $subname, |
70
|
|
|
|
|
|
|
code => $code, |
71
|
|
|
|
|
|
|
); |
72
|
3
|
|
|
|
|
9
|
$code; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
Sub::Install::install_sub({ |
75
|
|
|
|
|
|
|
into => __PACKAGE__, |
76
|
|
|
|
|
|
|
as => $type, |
77
|
|
|
|
|
|
|
code => $sub, |
78
|
|
|
|
|
|
|
}); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |