line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
11
|
|
|
11
|
|
5031
|
use 5.006; |
|
11
|
|
|
|
|
30
|
|
2
|
11
|
|
|
11
|
|
49
|
use strict; |
|
11
|
|
|
|
|
15
|
|
|
11
|
|
|
|
|
302
|
|
3
|
11
|
|
|
11
|
|
48
|
use warnings; |
|
11
|
|
|
|
|
13
|
|
|
11
|
|
|
|
|
709
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Set::Associate::RefillItems; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Pool re-population methods |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.004001'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
11
|
|
|
11
|
|
511
|
use Moose qw( has with ); |
|
11
|
|
|
|
|
339224
|
|
|
11
|
|
|
|
|
70
|
|
14
|
11
|
|
|
11
|
|
46808
|
use MooseX::AttributeShortcuts; |
|
11
|
|
|
|
|
284578
|
|
|
11
|
|
|
|
|
89
|
|
15
|
|
|
|
|
|
|
|
16
|
11
|
|
|
11
|
|
51254
|
use Set::Associate::Utils qw( _warn_nonmethod ); |
|
11
|
|
|
|
|
24
|
|
|
11
|
|
|
|
|
1387
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has name => ( |
27
|
|
|
|
|
|
|
isa => Str =>, |
28
|
|
|
|
|
|
|
is => rwp =>, |
29
|
|
|
|
|
|
|
required => 1, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has code => ( |
45
|
|
|
|
|
|
|
isa => CodeRef =>, |
46
|
|
|
|
|
|
|
is => rwp =>, |
47
|
|
|
|
|
|
|
required => 1, |
48
|
|
|
|
|
|
|
traits => ['Code'], |
49
|
|
|
|
|
|
|
handles => { |
50
|
|
|
|
|
|
|
get_all => execute_method =>, |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
has items => ( |
67
|
|
|
|
|
|
|
isa => ArrayRef =>, |
68
|
|
|
|
|
|
|
is => rwp =>, |
69
|
|
|
|
|
|
|
predicate => has_items =>, |
70
|
|
|
|
|
|
|
); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
with 'Set::Associate::Role::RefillItems' => { can_get_all => 1, }; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
75
|
|
|
|
|
|
|
|
76
|
11
|
|
|
11
|
|
54
|
no Moose; |
|
11
|
|
|
|
|
18
|
|
|
11
|
|
|
|
|
50
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub linear { |
100
|
4
|
50
|
|
4
|
1
|
83
|
shift @_ unless _warn_nonmethod( $_[0], __PACKAGE__, 'linear' ); |
101
|
4
|
|
|
|
|
2199
|
require Set::Associate::RefillItems::Linear; |
102
|
4
|
|
|
|
|
171
|
return Set::Associate::RefillItems::Linear->new(@_); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub shuffle { |
128
|
2
|
100
|
|
2
|
1
|
107
|
shift @_ unless _warn_nonmethod( $_[0], __PACKAGE__, 'shuffle' ); |
129
|
2
|
|
|
|
|
913
|
require Set::Associate::RefillItems::Shuffle; |
130
|
2
|
|
|
|
|
87
|
return Set::Associate::RefillItems::Shuffle->new(@_); |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
1; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
__END__ |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=pod |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=encoding UTF-8 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head1 NAME |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Set::Associate::RefillItems - Pool re-population methods |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 VERSION |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
version 0.004001 |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 DESCRIPTION |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This class implements a generalized interface for creating objects which populate pools. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
What you're mostly interested in are L</CLASS METHODS>, which are shorthand (somewhat) for loading and constructing |
154
|
|
|
|
|
|
|
many of the C<Set::Associate::RefillItems::*> family. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
However, if your code needs to design its own version on the fly, this interface should work: |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
my $populator = Set::Associate::RefillItems->new( |
159
|
|
|
|
|
|
|
name => 'foo', |
160
|
|
|
|
|
|
|
items => [ .... ], |
161
|
|
|
|
|
|
|
code => sub { |
162
|
|
|
|
|
|
|
my ( $self, $sa ) = @_; |
163
|
|
|
|
|
|
|
.... |
164
|
|
|
|
|
|
|
}, |
165
|
|
|
|
|
|
|
); |
166
|
|
|
|
|
|
|
my $sa = Set::Associate->new( |
167
|
|
|
|
|
|
|
on_item_empty => $populator , |
168
|
|
|
|
|
|
|
... |
169
|
|
|
|
|
|
|
); |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 CONSTRUCTOR ARGUMENTS |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 name |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
required Str |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 code |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
required CodeRef |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 items |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
required ArrayRef |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head1 CLASS METHODS |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 linear |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Populate from C<items> each time. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
See L<< C<Set::Associate::B<RefillItems::Linear>>|Set::Associate::RefillItems::Linear >> for details. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
my $sa = Set::Associate->new( |
194
|
|
|
|
|
|
|
... |
195
|
|
|
|
|
|
|
on_items_empty => Set::Associate::RefillItems->linear( items => [ ... ]) |
196
|
|
|
|
|
|
|
); |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
or ... |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
use Set::Associate::RefillItems::Linear; |
201
|
|
|
|
|
|
|
my $sa = Set::Associate->new( |
202
|
|
|
|
|
|
|
... |
203
|
|
|
|
|
|
|
on_items_empty => Set::Associate::RefillItems::Linear->new( items => [ ... ]) |
204
|
|
|
|
|
|
|
); |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head2 shuffle |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Populate with a shuffled version of C<items> |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
See L<< C<Set::Associate::B<RefillItems::Shuffle>>|Set::Associate::RefillItems::Shuffle >> for details. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
my $sa = Set::Associate->new( |
213
|
|
|
|
|
|
|
... |
214
|
|
|
|
|
|
|
on_items_empty => Set::Associate::RefillItems->shuffle( items => [ ... ]); |
215
|
|
|
|
|
|
|
); |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
or ... |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
use Set::Associate::RefillItems::Shuffle; |
220
|
|
|
|
|
|
|
my $sa = Set::Associate->new( |
221
|
|
|
|
|
|
|
... |
222
|
|
|
|
|
|
|
on_items_empty => Set::Associate::RefillItems::Shuffle->new( items => [ ... ]) |
223
|
|
|
|
|
|
|
); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 name |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=head2 code |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 items |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 ATTRIBUTE HANDLES |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 get_all |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
Invokes C<Trait:Code/execute_method> on L</code> |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 has_items |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Predicate method for L</items> |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 AUTHOR |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
252
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |