line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Class::Lego::Myself; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
107050
|
use 5.006; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
136
|
|
5
|
3
|
|
|
3
|
|
24
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
121
|
|
6
|
3
|
|
|
3
|
|
39
|
use warnings; |
|
3
|
|
|
|
|
14
|
|
|
3
|
|
|
|
|
224
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.003'; |
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
|
|
44
|
use Sub::Exporter -setup => { |
11
|
|
|
|
|
|
|
exports => [ qw(give_my_self) ], |
12
|
|
|
|
|
|
|
groups => { |
13
|
|
|
|
|
|
|
default => [ qw(give_my_self) ], |
14
|
|
|
|
|
|
|
} |
15
|
3
|
|
|
3
|
|
9891
|
}; |
|
3
|
|
|
|
|
56568
|
|
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
4619
|
use Scalar::Defer 0.13 (); |
|
3
|
|
|
|
|
61103
|
|
|
3
|
|
|
|
|
87
|
|
18
|
3
|
|
|
3
|
|
37
|
use Sub::Install (); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
68
|
|
19
|
3
|
|
|
3
|
|
16
|
use Carp qw( croak ); |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
1332
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub give_my_self { |
22
|
2
|
|
|
2
|
1
|
1734
|
my $self = shift; |
23
|
2
|
|
33
|
|
|
20
|
my $class = ref $self || $self; |
24
|
2
|
|
50
|
|
|
14
|
my $options = shift || {}; |
25
|
|
|
|
|
|
|
|
26
|
2
|
|
33
|
2
|
|
36
|
my $default = $options->{default} || Scalar::Defer::lazy(sub { $class->new }); |
|
2
|
|
|
|
|
250
|
|
27
|
2
|
50
|
|
|
|
47
|
if ( Scalar::Defer::is_deferred($default) ) { |
|
|
0
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# ok |
29
|
|
|
|
|
|
|
} elsif ( ref $default eq 'CODE' ) { |
30
|
|
|
|
|
|
|
# given a code, defer it |
31
|
0
|
|
|
|
|
0
|
$default = &Scalar::Defer::lazy($default); |
32
|
|
|
|
|
|
|
} else { |
33
|
0
|
|
|
|
|
0
|
croak "default should be a code ref"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
26
|
my $find_my_self = make_find_my_self( $default ); |
37
|
2
|
|
|
|
|
22
|
Sub::Install::install_sub({ |
38
|
|
|
|
|
|
|
code => $find_my_self, |
39
|
|
|
|
|
|
|
into => $class, |
40
|
|
|
|
|
|
|
as => 'find_my_self', |
41
|
|
|
|
|
|
|
}); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# my $get_default = sub { return $default }; |
44
|
|
|
|
|
|
|
# Sub::Install::install_sub({ |
45
|
|
|
|
|
|
|
# code => $get_default, |
46
|
|
|
|
|
|
|
# into => $class, |
47
|
|
|
|
|
|
|
# as => 'get_default', |
48
|
|
|
|
|
|
|
# }); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub make_find_my_self { |
53
|
2
|
|
|
2
|
0
|
6
|
my $default_object = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return sub { |
56
|
8
|
|
|
8
|
|
2202
|
my $self = shift; |
57
|
8
|
100
|
|
|
|
24
|
if ( !ref $self ) { |
58
|
6
|
|
|
|
|
11
|
$self = $default_object; |
59
|
|
|
|
|
|
|
} |
60
|
8
|
50
|
|
|
|
18
|
if ( wantarray ) { |
61
|
0
|
|
|
|
|
0
|
return $self, @_; |
62
|
|
|
|
|
|
|
} else { |
63
|
8
|
|
|
|
|
29
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
2
|
|
|
|
|
12
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
"me, myself and Zellweger"; |