line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Data::MultiValued::AttributeAccessors; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Data::MultiValued::AttributeAccessors::VERSION = '0.0.1_4'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
{ |
6
|
|
|
|
|
|
|
$Data::MultiValued::AttributeAccessors::DIST = 'Data-MultiValued'; |
7
|
|
|
|
|
|
|
} |
8
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
123
|
|
9
|
3
|
|
|
3
|
|
29
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
102
|
|
10
|
3
|
|
|
3
|
|
25
|
use base 'Moose::Meta::Method::Accessor'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
380
|
|
11
|
3
|
|
|
3
|
|
19
|
use Carp 'confess'; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
3044
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# ABSTRACT: method meta-class for multi-valued attribute accessors |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
0
|
|
0
|
sub _instance_is_inlinable { 0 } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub _generate_accessor_method { |
20
|
7
|
|
|
7
|
|
5772
|
my $self = shift; |
21
|
7
|
|
|
|
|
56
|
my $attr = $self->associated_attribute; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
return sub { |
24
|
12
|
50
|
|
12
|
|
29090
|
if (@_ >= 2) { |
|
|
|
|
4
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
8
|
|
|
|
25
|
0
|
|
|
|
|
0
|
$attr->set_multi_value($_[0], {}, $_[1]); |
26
|
|
|
|
|
|
|
} |
27
|
12
|
|
|
|
|
81
|
$attr->get_multi_value($_[0], {}); |
28
|
|
|
|
|
|
|
} |
29
|
7
|
|
|
|
|
74
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _generate_reader_method { |
32
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
33
|
0
|
|
|
|
|
0
|
my $attr = $self->associated_attribute; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return sub { |
36
|
0
|
0
|
|
0
|
|
0
|
confess "Cannot assign a value to a read-only accessor" |
37
|
|
|
|
|
|
|
if @_ > 1; |
38
|
0
|
|
|
|
|
0
|
$attr->get_multi_value($_[0], {}); |
39
|
0
|
|
|
|
|
0
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _generate_writer_method { |
43
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
44
|
0
|
|
|
|
|
0
|
my $attr = $self->associated_attribute; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return sub { |
47
|
0
|
|
|
0
|
|
0
|
$attr->set_multi_value($_[0], {}, $_[1]); |
48
|
0
|
|
|
|
|
0
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub _generate_predicate_method { |
52
|
7
|
|
|
7
|
|
2241
|
my $self = shift; |
53
|
7
|
|
|
|
|
26
|
my $attr = $self->associated_attribute; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
return sub { |
56
|
12
|
|
|
12
|
|
5304
|
$attr->has_multi_value($_[0], {}) |
|
|
|
|
12
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
0
|
|
|
|
57
|
7
|
|
|
|
|
63
|
}; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _generate_clearer_method { |
61
|
7
|
|
|
7
|
|
2058
|
my $self = shift; |
62
|
7
|
|
|
|
|
21
|
my $attr = $self->associated_attribute; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return sub { |
65
|
0
|
|
|
0
|
|
0
|
$attr->clear_multi_value($_[0], {}) |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
66
|
7
|
|
|
|
|
71
|
}; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _generate_multi_accessor_method { |
71
|
7
|
|
|
7
|
|
2264
|
my $self = shift; |
72
|
7
|
|
|
|
|
23
|
my $attr = $self->associated_attribute; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
return sub { |
75
|
14
|
100
|
|
14
|
|
9170
|
if (@_ >= 3) { |
|
|
|
|
14
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
6
|
|
|
|
76
|
6
|
|
|
|
|
47
|
$attr->set_multi_value($_[0], $_[1], $_[2]); |
77
|
|
|
|
|
|
|
} |
78
|
14
|
|
|
|
|
129
|
$attr->get_multi_value($_[0],$_[1]); |
79
|
|
|
|
|
|
|
} |
80
|
7
|
|
|
|
|
79
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub _generate_multi_reader_method { |
83
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
84
|
0
|
|
|
|
|
0
|
my $attr = $self->associated_attribute; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
return sub { |
87
|
0
|
0
|
|
0
|
|
0
|
confess "Cannot assign a value to a read-only accessor" |
88
|
|
|
|
|
|
|
if @_ > 2; |
89
|
0
|
|
|
|
|
0
|
$attr->get_multi_value($_[0],$_[1]); |
90
|
0
|
|
|
|
|
0
|
}; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _generate_multi_writer_method { |
94
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
95
|
0
|
|
|
|
|
0
|
my $attr = $self->associated_attribute; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
return sub { |
98
|
0
|
|
|
0
|
|
0
|
$attr->set_multi_value($_[0], $_[1], $_[2]); |
99
|
0
|
|
|
|
|
0
|
}; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub _generate_multi_predicate_method { |
103
|
7
|
|
|
7
|
|
2247
|
my $self = shift; |
104
|
7
|
|
|
|
|
34
|
my $attr = $self->associated_attribute; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return sub { |
107
|
4
|
|
|
4
|
|
2261
|
$attr->has_multi_value($_[0],$_[1]) |
|
|
|
|
4
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
0
|
|
|
|
108
|
7
|
|
|
|
|
79
|
}; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub _generate_multi_clearer_method { |
112
|
7
|
|
|
7
|
|
2197
|
my $self = shift; |
113
|
7
|
|
|
|
|
23
|
my $attr = $self->associated_attribute; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
return sub { |
116
|
0
|
|
|
0
|
|
|
$attr->clear_multi_value($_[0],$_[1]) |
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
4
|
|
|
|
117
|
7
|
|
|
|
|
76
|
}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |
123
|
|
|
|
|
|
|
=pod |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=encoding utf-8 |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 NAME |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Data::MultiValued::AttributeAccessors - method meta-class for multi-valued attribute accessors |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 VERSION |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
version 0.0.1_4 |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head1 DESCRIPTION |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Subclass of L<Moose::Meta::Method::Accessor>, generates non-inlined |
138
|
|
|
|
|
|
|
(patches welcome) accessors for multi-valued attributes. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 METHODS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 C<_instance_is_inlinable> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Returns C<0> to prevent attempts to inline the accessor methods. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 C<_generate_accessor_method> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 C<_generate_reader_method> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 C<_generate_writer_method> |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head2 C<_generate_predicate_method> |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 C<_generate_clearer_method> |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Delegate to C<set_multi_value>, C<get_multi_value>, |
157
|
|
|
|
|
|
|
C<has_multi_value>, C<clear_multi_value>, passing empty options |
158
|
|
|
|
|
|
|
(i.e. no tags, no ranges). |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=head2 C<_generate_multi_accessor_method> |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 C<_generate_multi_reader_method> |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head2 C<_generate_multi_writer_method> |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 C<_generate_multi_predicate_method> |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 C<_generate_multi_clearer_method> |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Delegate to C<set_multi_value>, C<get_multi_value>, |
171
|
|
|
|
|
|
|
C<has_multi_value>, C<clear_multi_value>, passing C<$_[1]> as options |
172
|
|
|
|
|
|
|
and C<$_[2]> as values. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 AUTHOR |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Gianni Ceccarelli <dakkar@thenautilus.net> |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Net-a-Porter.com. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
183
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|