| 1 | #!/usr/bin/perl | |||||||||||||||||||||
| 2 | ||||||||||||||||||||||
| 3 | package KiokuDB::Role::UUIDs; | |||||||||||||||||||||
| 4 | 21 | ▶ | use Moose::Role; | |||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||
| 5 | ||||||||||||||||||||||
| 6 | 21 | ▶ | use Try::Tiny; | |||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||
| 7 | ||||||||||||||||||||||
| 8 | 21 | ▶ | use namespace::clean -except => 'meta'; | |||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| ||||||||||||||||||||||
| 9 | ||||||||||||||||||||||
| 10 | 21 | ▶ | if ( defined &KiokuDB::SERIAL_IDS and KiokuDB::SERIAL_IDS() ) { | |||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined &KiokuDB::SERIAL_IDS and !!0
MC/DC100%1/1
defined &KiokuDB::SERIAL_IDS and !!0
defined &KiokuDB::SERIAL_IDS
Truth table100%2/2
A
A= defined &KiokuDB::SERIAL_IDS
| ||||||||||||||||||||||
| 11 | 1 | with qw(KiokuDB::Role::UUIDs::SerialIDs); | ||||||||||||||||||||
| 12 | } else { | |||||||||||||||||||||
| 13 | 20 | ▶ | my $have_libuuid = try { require Data::UUID::LibUUID; 1 }; | |||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.4
| ||||||||||||||||||||||
| 14 | ||||||||||||||||||||||
| 15 | 20 | ▶ | my $backend = $have_libuuid ? "LibUUID" : "DataUUID"; | |||||||||||||||||||
|
Branch: 1 branch
| ||||||||||||||||||||||
| 16 | ||||||||||||||||||||||
| 17 | 20 | with "KiokuDB::Role::UUIDs::$backend"; | ||||||||||||||||||||
| 18 | } | |||||||||||||||||||||
| 19 | ||||||||||||||||||||||
| 20 | 21 | __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 | |||||||||||||||||||||