| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Util::Underscore::Objects; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#ABSTRACT: Functions for introspecting and manipulating objects and classes |
|
4
|
|
|
|
|
|
|
|
|
5
|
12
|
|
|
12
|
|
96
|
use strict; |
|
|
12
|
|
|
|
|
27
|
|
|
|
12
|
|
|
|
|
285
|
|
|
6
|
12
|
|
|
12
|
|
58
|
use warnings; |
|
|
12
|
|
|
|
|
23
|
|
|
|
12
|
|
|
|
|
585
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## no critic (ProhibitMultiplePackages) |
|
10
|
|
|
|
|
|
|
package # hide from PAUSE |
|
11
|
|
|
|
|
|
|
_; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## no critic (RequireArgUnpacking, RequireFinalReturn, ProhibitSubroutinePrototypes) |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub blessed(_) { |
|
16
|
141
|
|
|
141
|
|
13093
|
goto &Scalar::Util::blessed; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ |
|
20
|
12
|
|
|
12
|
|
65
|
no warnings 'once'; ## no critic (ProhibitNoWarnings) |
|
|
12
|
|
|
|
|
24
|
|
|
|
12
|
|
|
|
|
2665
|
|
|
21
|
|
|
|
|
|
|
*class = \&blessed; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub is_object(_) { |
|
25
|
11
|
|
|
11
|
|
2569
|
defined blessed $_[0]; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub class_isa($$) { |
|
29
|
5
|
100
|
|
5
|
|
1697
|
is_package($_[0]) |
|
30
|
|
|
|
|
|
|
&& $_[0]->isa($_[1]); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub class_does($$) { |
|
34
|
5
|
100
|
|
5
|
|
2077
|
is_package($_[0]) |
|
35
|
|
|
|
|
|
|
&& $_[0]->DOES($_[1]); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub class_can($$) { |
|
39
|
5
|
100
|
|
5
|
|
1666
|
is_package($_[0]) |
|
40
|
|
|
|
|
|
|
&& $_[0]->can($_[1]); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub isa($$) { |
|
44
|
5
|
100
|
|
5
|
|
1821
|
blessed $_[0] |
|
45
|
|
|
|
|
|
|
&& $_[0]->isa($_[1]); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub does($$) { |
|
49
|
5
|
100
|
|
5
|
|
2078
|
blessed $_[0] |
|
50
|
|
|
|
|
|
|
&& $_[0]->DOES($_[1]); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ |
|
54
|
12
|
|
|
12
|
|
76
|
no warnings 'once'; ## no critic (ProhibitNoWarnings) |
|
|
12
|
|
|
|
|
21
|
|
|
|
12
|
|
|
|
|
1331
|
|
|
55
|
|
|
|
|
|
|
*is_instance = \&does; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub can($$) { |
|
59
|
5
|
100
|
|
5
|
|
1669
|
blessed $_[0] |
|
60
|
|
|
|
|
|
|
&& $_[0]->can($_[1]); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub safecall($$@) { |
|
64
|
11
|
|
|
11
|
|
4067
|
my $self = shift; |
|
65
|
11
|
|
|
|
|
22
|
my $meth = shift; |
|
66
|
11
|
100
|
|
|
|
25
|
return if not blessed $self; |
|
67
|
5
|
|
|
|
|
39
|
$self->$meth(@_); |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |