SPOPS/Key/Random.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 48 CC 3 SCAR 16.7
CC
3
Cov
0%
pre_fetch_id
12.0
post_fetch_id
2.0
BEGIN
2.0
CRAP 5.3
1 package SPOPS::Key::Random;
2  
3 # $Id: Random.pm,v 3.4 2004/06/02 00:48:23 lachoy Exp $
4  
5 use strict;
6 use Log::Log4perl qw( get_logger );
7 use SPOPS;
8 use SPOPS::Utility;
9  
10 $SPOPS::Key::Random::VERSION = sprintf("%d.%02d", q$Revision: 3.4 $ =~ /(\d+)\.(\d+)/);
11  
12 use constant DEFAULT_ID_WIDTH => 8;
13  
14 my $log = get_logger();
15  
16 sub pre_fetch_id {
17 my ( $class, $p ) = @_;
18 my $width = $p->{id_width};
19 unless ( $width ) {
20 my $config = eval { $class->CONFIG };
21 if ( ref $config ) {
22 $width = $class->CONFIG->{id_width};
23 }
24 $width ||= DEFAULT_ID_WIDTH;
25 }
26 my $code = SPOPS::Utility->generate_random_code( $width );
27 $log->warn( "Created insert ID [$code]" );
28 return ( $code, 1 );
29 }
30  
31 sub post_fetch_id { return undef }
32  
33 1;
34  
35 __END__