blib/lib/Set/Associate/NewKey/RandomPick.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 31 CC 1 SCAR 6.9
CC
1
Cov
0%
name
2.0
get_assoc
2.0
BEGIN
2.0
CRAP 2.0
1 use 5.006;
2 use strict;
3 use warnings;
4  
5 package Set::Associate::NewKey::RandomPick;
6  
7 # ABSTRACT: Associate a key by randomly picking from a pool
8  
9 our $VERSION = '0.004000';
10  
11 our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12  
13 use Moose qw( with );
14  
15 with 'Set::Associate::Role::NewKey' => { can_get_assoc => 1, };
16  
17 __PACKAGE__->meta->make_immutable;
18  
19 no Moose;
20  
21  
22  
23  
24  
25  
26  
27 sub name { 'random_pick' }
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39 sub get_assoc {
40 return $_[1]->_items_cache_get( int( rand( $_[1]->_items_cache_count ) ) );
41 }
42  
43 1;
44  
45 __END__
46  
47 =pod
48  
49 =encoding UTF-8
50  
51 =head1 NAME
52  
53 Set::Associate::NewKey::RandomPick - Associate a key by randomly picking from a pool
54  
55 =head1 VERSION
56  
57 version 0.004000
58  
59 =head1 METHODS
60  
61 =head2 name
62  
63 The name of this key assignment method ( C<random_pick> )
64  
65 =head2 get_assoc
66  
67 Returns a value non-destructively at random from C<$set_assoc>'s pool.
68  
69 C<$new_key> is ignored with this method.
70  
71 my $value = $object->get_assoc( $set_assoc, $new_key );
72  
73 =head1 AUTHOR
74  
75 Kent Fredric <kentnl@cpan.org>
76  
77 =head1 COPYRIGHT AND LICENSE
78  
79 This software is copyright (c) 2015 by Kent Fredric <kentfredric@gmail.com>.
80  
81 This is free software; you can redistribute it and/or modify it under
82 the same terms as the Perl 5 programming language system itself.
83  
84 =cut