File Coverage

blib/lib/KiokuDB/Role/UUIDs.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2              
3             package KiokuDB::Role::UUIDs;
4 21     21   11450 use Moose::Role;
  21         35  
  21         177  
5              
6 21     21   90060 use Try::Tiny;
  21         43  
  21         1323  
7              
8 21     21   107 use namespace::clean -except => 'meta';
  21         36  
  21         158  
9              
10             if ( defined &KiokuDB::SERIAL_IDS and KiokuDB::SERIAL_IDS() ) {
11             with qw(KiokuDB::Role::UUIDs::SerialIDs);
12             } else {
13             my $have_libuuid = try { require Data::UUID::LibUUID; 1 };
14              
15             my $backend = $have_libuuid ? "LibUUID" : "DataUUID";
16              
17             with "KiokuDB::Role::UUIDs::$backend";
18             }
19              
20             __PACKAGE__
21              
22             __END__
23              
24             =pod
25              
26             =head1 NAME
27              
28             KiokuDB::Role::UUIDs - UUID generation role.
29              
30             =head1 SYNOPSIS
31              
32             with qw(KiokuDB::Role::UUIDs);
33              
34             =head1 DESCRIPTION
35              
36             This role provides UUID assignment.
37              
38             Depending on the C<$SERIAL_IDS> variable being true at compile time, and
39             availability of UUID generation module (L<Data::UUID::LibUUID> falling back to
40             L<Data::UUID>) an implementation role is selected.
41              
42             =head1 METHODS
43              
44             =over 4
45              
46             =item generate_uuid
47              
48             Create a new UUID
49              
50             =back
51              
52             =cut