line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Generate::ClassAccessor; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
21902
|
use 5.008; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
232
|
|
4
|
5
|
|
|
5
|
|
31
|
use strict; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
206
|
|
5
|
5
|
|
|
5
|
|
28
|
use warnings; |
|
5
|
|
|
|
|
27
|
|
|
5
|
|
|
|
|
190
|
|
6
|
5
|
|
|
5
|
|
25
|
no warnings qw( void once uninitialized numeric ); |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
354
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
5
|
|
|
5
|
|
25
|
no warnings 'once'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
498
|
|
10
|
5
|
|
|
5
|
|
13
|
$Method::Generate::ClassAccessor::AUTHORITY = 'cpan:TOBYINK'; |
11
|
5
|
|
|
|
|
121
|
$Method::Generate::ClassAccessor::VERSION = '0.010'; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
5
|
|
|
5
|
|
30
|
use B 'perlstring'; |
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
568
|
|
15
|
|
|
|
|
|
|
|
16
|
5
|
|
|
5
|
|
34
|
use base qw(Method::Generate::Accessor); |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
4824
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub generate_method |
19
|
|
|
|
|
|
|
{ |
20
|
10
|
|
|
10
|
1
|
871
|
my ($self, $into, $name, $spec, $quote_opts) = @_; |
21
|
10
|
|
|
|
|
26
|
local $Method::Generate::Accessor::CAN_HAZ_XS = 0; # sorry |
22
|
10
|
|
33
|
|
|
65
|
$spec->{_classy} ||= $into; |
23
|
10
|
|
|
|
|
80
|
my $r = $self->SUPER::generate_method($into, $name, $spec, $quote_opts); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Populate default value |
26
|
10
|
50
|
|
|
|
1206
|
unless ($spec->{lazy}) |
27
|
|
|
|
|
|
|
{ |
28
|
10
|
|
|
|
|
18
|
my $storage = do { |
29
|
5
|
|
|
5
|
|
102472
|
no strict 'refs'; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
2211
|
|
30
|
10
|
|
|
|
|
18
|
\%{"$spec->{_classy}\::__ClassAttributeValues"}; |
|
10
|
|
|
|
|
62
|
|
31
|
|
|
|
|
|
|
}; |
32
|
|
|
|
|
|
|
|
33
|
10
|
|
|
|
|
17
|
my $default; |
34
|
10
|
100
|
|
|
|
205
|
if (ref($default = $spec->{default})) |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
35
|
|
|
|
|
|
|
{ |
36
|
4
|
|
|
|
|
21
|
$storage->{$name} = $default->($into); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
elsif ($default = $spec->{default}) |
39
|
|
|
|
|
|
|
{ |
40
|
1
|
|
|
|
|
3
|
$storage->{$name} = $default; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ($default = $spec->{builder}) |
43
|
|
|
|
|
|
|
{ |
44
|
0
|
|
|
|
|
0
|
$storage->{$name} = $into->$default; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
10
|
|
|
|
|
86
|
return $r; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _generate_simple_get |
52
|
|
|
|
|
|
|
{ |
53
|
12
|
|
|
12
|
|
520
|
my ($self, $me, $name, $spec) = @_; |
54
|
12
|
|
|
|
|
27
|
my $classy = $spec->{_classy}; |
55
|
12
|
|
|
|
|
31
|
"\$$classy\::__ClassAttributeValues{${\perlstring $name}}"; |
|
12
|
|
|
|
|
97
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _generate_core_set |
59
|
|
|
|
|
|
|
{ |
60
|
11
|
|
|
11
|
|
1367
|
my ($self, $me, $name, $spec, $value) = @_; |
61
|
11
|
|
|
|
|
25
|
my $classy = $spec->{_classy}; |
62
|
11
|
|
|
|
|
28
|
"\$$classy\::__ClassAttributeValues{${\perlstring $name}} = $value"; |
|
11
|
|
|
|
|
70
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _generate_simple_has |
66
|
|
|
|
|
|
|
{ |
67
|
2
|
|
|
2
|
|
104
|
my ($self, $me, $name, $spec) = @_; |
68
|
2
|
|
|
|
|
4
|
my $classy = $spec->{_classy}; |
69
|
2
|
|
|
|
|
4
|
"exists \$$classy\::__ClassAttributeValues{${\perlstring $name}}"; |
|
2
|
|
|
|
|
19
|
|
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _generate_simple_clear |
73
|
|
|
|
|
|
|
{ |
74
|
1
|
|
|
1
|
|
85
|
my ($self, $me, $name, $spec) = @_; |
75
|
1
|
|
|
|
|
3
|
my $classy = $spec->{_classy}; |
76
|
1
|
|
|
|
|
13
|
"delete \$$classy\::__ClassAttributeValues{${\perlstring $name}}"; |
|
1
|
|
|
|
|
8
|
|
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 NAME |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Method::Generate::ClassAccessor - generate class accessor method |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 DESCRIPTION |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
This class inherits from L<Method::Generate::Accessor>; see the very fine |
90
|
|
|
|
|
|
|
documentation for that module. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This class overrides the following methods: |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=over |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=item C<generate_method> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item C<_generate_simple_get> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item C<_generate_core_set> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item C<_generate_simple_has> |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item C<_generate_simple_clear> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=back |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 CAVEATS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
B<< Moo 1.001000 has a bug that breaks this module. >> |
111
|
|
|
|
|
|
|
Any other Moo should be fine and dandy. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 BUGS |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Please report any bugs to |
116
|
|
|
|
|
|
|
L<http://rt.cpan.org/Dist/Display.html?Queue=MooX-ClassAttribute>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SEE ALSO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
L<Method::Generate::Accessor>, |
121
|
|
|
|
|
|
|
L<MooX::ClassAttribute>. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 AUTHOR |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Toby Inkster E<lt>tobyink@cpan.orgE<gt>. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Toby Inkster. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
132
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTIES |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED |
137
|
|
|
|
|
|
|
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF |
138
|
|
|
|
|
|
|
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
139
|
|
|
|
|
|
|
|