line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Noose; |
2
|
6
|
|
|
6
|
|
136342
|
use strict; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
195
|
|
3
|
6
|
|
|
6
|
|
31
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
240
|
|
4
|
|
|
|
|
|
|
# ABSTRACT: just enough object orientation to hang yourself |
5
|
|
|
|
|
|
|
our $VERSION = '0.001'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
6
|
|
|
6
|
|
4874
|
use Sub::Name; |
|
6
|
|
|
|
|
20310
|
|
|
6
|
|
|
|
|
612
|
|
8
|
6
|
|
|
6
|
|
55
|
use Scalar::Util qw(blessed); |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
1448
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
5
|
|
|
5
|
|
47
|
my $class = caller; |
14
|
|
|
|
|
|
|
|
15
|
5
|
|
|
|
|
19
|
my $sub_name = $class . '::new'; |
16
|
5
|
|
|
|
|
20
|
my $sub_code = \&new; |
17
|
5
|
|
|
|
|
47
|
subname $sub_name => $sub_code; |
18
|
|
|
|
|
|
|
{ |
19
|
6
|
|
|
6
|
|
36
|
no strict 'refs'; ## no critic (TestingAndDebugging::ProhibitNoStrict) |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
2656
|
|
|
5
|
|
|
|
|
41
|
|
20
|
5
|
|
|
|
|
12
|
*{$sub_name} = $sub_code; |
|
5
|
|
|
|
|
1016
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
26
|
10
|
|
|
10
|
|
20514
|
my $class = shift; |
27
|
10
|
|
|
|
|
21
|
my %args = do { |
28
|
10
|
100
|
|
|
|
65
|
if ( blessed $class ) { # If it was called as an object method, |
29
|
2
|
|
|
|
|
1623
|
require Storable; |
30
|
2
|
|
|
|
|
5032
|
Storable->import(qw/dclone/); # We're going to clone the object it was called on |
31
|
2
|
100
|
|
|
|
9
|
if (@_) { # Add in some args if there were any |
32
|
1
|
|
|
|
|
881
|
require Acme::Damn; # HINT HINT |
33
|
1
|
|
|
|
|
1468
|
Acme::Damn->import(qw/damn/); |
34
|
1
|
|
|
|
|
76
|
( %{ damn( dclone($class) ) }, @_ ); # These args will be used to construct the returned object |
|
1
|
|
|
|
|
245
|
|
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { # Otherwise, just return the clone |
37
|
1
|
|
|
|
|
51
|
return dclone($class); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else { # Called as a normal constructor, nothing exciting here |
41
|
8
|
|
|
|
|
34
|
@_; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
}; |
44
|
9
|
100
|
|
|
|
53
|
$class = blessed $class if blessed $class; # Can't bless into a reference, we need the package name |
45
|
|
|
|
|
|
|
|
46
|
9
|
|
|
|
|
38
|
foreach my $attr (keys %args) { |
47
|
|
|
|
|
|
|
my $sub_code = sub { |
48
|
20
|
100
|
|
20
|
|
16635
|
@_ > 1 |
|
|
|
|
32
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
1
|
|
|
|
49
|
|
|
|
|
|
|
? $_[0]->{$attr} = $_[1] |
50
|
|
|
|
|
|
|
: $_[0]->{$attr}; |
51
|
13
|
|
|
|
|
61
|
}; |
52
|
|
|
|
|
|
|
|
53
|
13
|
|
|
|
|
37
|
my $sub_name = $class . '::' . $attr; |
54
|
13
|
|
|
|
|
105
|
subname $sub_name => $sub_code; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
{ |
57
|
6
|
|
|
6
|
|
45
|
no warnings qw(redefine); |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
424
|
|
|
13
|
|
|
|
|
33
|
|
58
|
6
|
|
|
6
|
|
32
|
no strict qw(refs); ## no critic (TestingAndDebugging::ProhibitNoStrict) |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
645
|
|
59
|
13
|
|
|
|
|
18
|
*{$sub_name} = $sub_code; |
|
13
|
|
|
|
|
94
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
9
|
|
|
|
|
58
|
return bless { %args }, $class; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |