File Coverage

blib/lib/Set/Associate/RefillItems/Shuffle.pm
Criterion Covered Total %
statement 19 20 95.0
branch n/a
condition n/a
subroutine 7 8 87.5
pod 2 2 100.0
total 28 30 93.3


line stmt bran cond sub pod time code
1 4     4   911 use 5.006;
  4         9  
2 4     4   19 use strict;
  4         5  
  4         124  
3 4     4   17 use warnings;
  4         5  
  4         303  
4              
5             package Set::Associate::RefillItems::Shuffle;
6              
7             # ABSTRACT: a refill method that replenishes the cache with a shuffled list
8              
9             our $VERSION = '0.004001';
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 4     4   460 use Moose qw( with has );
  4         301098  
  4         29  
14              
15             with 'Set::Associate::Role::RefillItems' => { can_get_all => 1, };
16              
17              
18              
19              
20              
21              
22              
23              
24              
25             has items => ( isa => 'ArrayRef', is => 'rw', required => 1 );
26              
27             __PACKAGE__->meta->make_immutable;
28              
29 4     4   17128 no Moose;
  4         6  
  4         14  
30              
31              
32              
33              
34              
35              
36              
37 0     0 1 0 sub name { 'shuffle' }
38              
39 4     4   390 use List::Util qw( shuffle );
  4         4  
  4         464  
40              
41              
42              
43              
44              
45              
46              
47 4     4 1 5 sub get_all { return shuffle( @{ $_[0]->items } ) }
  4         122  
48              
49             1;
50              
51             __END__
52              
53             =pod
54              
55             =encoding UTF-8
56              
57             =head1 NAME
58              
59             Set::Associate::RefillItems::Shuffle - a refill method that replenishes the cache with a shuffled list
60              
61             =head1 VERSION
62              
63             version 0.004001
64              
65             =head1 CONSTRUCTOR ARGUMENTS
66              
67             =head2 items
68              
69             required ArrayRef
70              
71             =head1 METHODS
72              
73             =head2 name
74              
75             The name of this refill method ( C<shuffle> )
76              
77             =head2 get_all
78              
79             Get a new copy of C<items> in shuffled form.
80              
81             =head1 ATTRIBUTES
82              
83             =head2 items
84              
85             =head1 AUTHOR
86              
87             Kent Fredric <kentnl@cpan.org>
88              
89             =head1 COPYRIGHT AND LICENSE
90              
91             This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
92              
93             This is free software; you can redistribute it and/or modify it under
94             the same terms as the Perl 5 programming language system itself.
95              
96             =cut