line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
59
|
use 5.010; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
155
|
|
2
|
4
|
|
|
4
|
|
29
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
93
|
|
3
|
4
|
|
|
4
|
|
18
|
use strict; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
188
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Brickyard::Accessor; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
4
|
|
|
4
|
|
676
|
$Brickyard::Accessor::VERSION = '1.111750'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: Accessor generator for Brickyard classes |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub import { |
13
|
20
|
|
|
20
|
|
191998
|
shift; |
14
|
20
|
|
|
|
|
71
|
my %args = @_; |
15
|
20
|
|
|
|
|
50
|
my $pkg = caller(0); |
16
|
20
|
|
|
|
|
128
|
my %key_ctor = (rw => \&_mk_accessors); |
17
|
20
|
|
|
|
|
83
|
for my $key (sort keys %key_ctor) { |
18
|
20
|
50
|
|
|
|
74
|
next unless $args{$key}; |
19
|
20
|
50
|
|
|
|
67
|
die "value of the '$key' parameter should be an arrayref" |
20
|
|
|
|
|
|
|
unless ref $args{$key} eq 'ARRAY'; |
21
|
20
|
|
|
|
|
32
|
$key_ctor{$key}->($pkg, @{ $args{$key} }); |
|
20
|
|
|
|
|
69
|
|
22
|
|
|
|
|
|
|
} |
23
|
20
|
100
|
|
|
|
84
|
_mk_new($pkg) if $args{new}; |
24
|
20
|
|
|
|
|
5333
|
1; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _mk_new { |
28
|
9
|
|
|
9
|
|
19
|
my $pkg = shift; |
29
|
4
|
|
|
4
|
|
25
|
no strict 'refs'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
405
|
|
30
|
9
|
|
|
|
|
75
|
*{"${pkg}::new"} = sub { |
31
|
21
|
|
|
21
|
|
68
|
my $class = shift; |
32
|
21
|
|
|
|
|
230
|
bless {@_}, $class; |
33
|
9
|
|
|
|
|
45
|
}; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _mk_accessors { |
37
|
20
|
|
|
20
|
|
36
|
my $pkg = shift; |
38
|
20
|
|
|
|
|
43
|
for my $n (@_) { |
39
|
4
|
|
|
4
|
|
23
|
no strict 'refs'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
485
|
|
40
|
39
|
|
|
|
|
80
|
*{"${pkg}::${n}"} = __make_rw($n); |
|
39
|
|
|
|
|
267
|
|
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub __make_rw { |
45
|
39
|
|
|
39
|
|
55
|
my $n = shift; |
46
|
|
|
|
|
|
|
sub { |
47
|
95
|
100
|
|
95
|
|
1229
|
$_[0]->{$n} = $_[1] if @_ == 2; |
48
|
95
|
|
|
|
|
522
|
$_[0]->{$n}; |
49
|
39
|
|
|
|
|
159
|
}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |