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
|
|
40
|
use strict; |
|
12
|
|
|
|
|
13
|
|
|
12
|
|
|
|
|
260
|
|
6
|
12
|
|
|
12
|
|
49
|
use warnings; |
|
12
|
|
|
|
|
14
|
|
|
12
|
|
|
|
|
525
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
## no critic (ProhibitMultiplePackages) |
10
|
|
|
|
|
|
|
package # hide from PAUSE |
11
|
|
|
|
|
|
|
_; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
## no critic (RequireArgUnpacking, RequireFinalReturn, ProhibitSubroutinePrototypes) |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub blessed(_) { |
16
|
138
|
|
|
138
|
|
7188
|
goto &Scalar::Util::blessed; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
{ |
20
|
12
|
|
|
12
|
|
36
|
no warnings 'once'; ## no critic (ProhibitNoWarnings) |
|
12
|
|
|
|
|
15
|
|
|
12
|
|
|
|
|
2315
|
|
21
|
|
|
|
|
|
|
*class = \&blessed; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub is_object(_) { |
25
|
11
|
|
|
11
|
|
1310
|
defined blessed $_[0]; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub class_isa($$) { |
29
|
4
|
50
|
|
4
|
|
863
|
is_package($_[0]) |
30
|
|
|
|
|
|
|
&& $_[0]->isa($_[1]); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub class_does($$) { |
34
|
4
|
50
|
|
4
|
|
1168
|
is_package($_[0]) |
35
|
|
|
|
|
|
|
&& $_[0]->DOES($_[1]); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub class_can($$) { |
39
|
4
|
50
|
|
4
|
|
890
|
is_package($_[0]) |
40
|
|
|
|
|
|
|
&& $_[0]->can($_[1]); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub isa($$) { |
44
|
4
|
50
|
|
4
|
|
864
|
blessed $_[0] |
45
|
|
|
|
|
|
|
&& $_[0]->isa($_[1]); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub does($$) { |
49
|
4
|
50
|
|
4
|
|
988
|
blessed $_[0] |
50
|
|
|
|
|
|
|
&& $_[0]->DOES($_[1]); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
{ |
54
|
12
|
|
|
12
|
|
43
|
no warnings 'once'; ## no critic (ProhibitNoWarnings) |
|
12
|
|
|
|
|
14
|
|
|
12
|
|
|
|
|
1286
|
|
55
|
|
|
|
|
|
|
*is_instance = \&does; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub can($$) { |
59
|
4
|
50
|
|
4
|
|
866
|
blessed $_[0] |
60
|
|
|
|
|
|
|
&& $_[0]->can($_[1]); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub safecall($$@) { |
64
|
11
|
|
|
11
|
|
2273
|
my $self = shift; |
65
|
11
|
|
|
|
|
12
|
my $meth = shift; |
66
|
11
|
100
|
|
|
|
22
|
return if not blessed $self; |
67
|
5
|
|
|
|
|
30
|
$self->$meth(@_); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |