| 1 | use 5.006; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | package Set::Associate::NewKey::HashSHA1; | ||
| 6 | |||
| 7 | # ABSTRACT: Pick a value from the pool based on the SHA1 value of the key | ||
| 8 | |||
| 9 | our $VERSION = '0.004000'; | ||
| 10 | |||
| 11 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | ||
| 12 | |||
| 13 | use Moose qw( around extends ); | ||
| 14 | use Digest::SHA1; | ||
| 15 | use bigint 0.22 qw( hex ); | ||
| 16 | extends 'Set::Associate::NewKey::PickOffset'; | ||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | sub name { 'hash_sha1' } | ||
| 25 | |||
| 26 | around get_assoc => sub { | ||
| 27 | my ( $orig, $self, $sa, $key ) = @_; | ||
| 28 | return $self->$orig( $sa, hex Digest::SHA1::sha1_hex($key) ); | ||
| 29 | }; | ||
| 30 | |||
| 31 | __PACKAGE__->meta->make_immutable; | ||
| 32 | |||
| 33 | no Moose; | ||
| 34 | |||
| 35 | 1; | ||
| 36 | |||
| 37 | __END__ | ||
| 38 | |||
| 39 | =pod | ||
| 40 | |||
| 41 | =encoding UTF-8 | ||
| 42 | |||
| 43 | =head1 NAME | ||
| 44 | |||
| 45 | Set::Associate::NewKey::HashSHA1 - Pick a value from the pool based on the SHA1 value of the key | ||
| 46 | |||
| 47 | =head1 VERSION | ||
| 48 | |||
| 49 | version 0.004000 | ||
| 50 | |||
| 51 | =head1 METHODS | ||
| 52 | |||
| 53 | =head2 name | ||
| 54 | |||
| 55 | The name of this key assignment method ( C<hash_sha1> ) | ||
| 56 | |||
| 57 | =head1 AUTHOR | ||
| 58 | |||
| 59 | Kent Fredric <kentnl@cpan.org> | ||
| 60 | |||
| 61 | =head1 COPYRIGHT AND LICENSE | ||
| 62 | |||
| 63 | This software is copyright (c) 2015 by Kent Fredric <kentfredric@gmail.com>. | ||
| 64 | |||
| 65 | This is free software; you can redistribute it and/or modify it under | ||
| 66 | the same terms as the Perl 5 programming language system itself. | ||
| 67 | |||
| 68 | =cut |