File Coverage

blib/lib/KiokuDB/Role/Upgrade/Handlers/Table.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 17 18 94.4


line stmt bran cond sub pod time code
1             package KiokuDB::Role::Upgrade::Handlers::Table;
2 2     2   4868 use Moose::Role;
  2         4  
  2         14  
3              
4 2     2   8487 use namespace::clean;
  2         3  
  2         16  
5              
6             with qw(KiokuDB::Role::Upgrade::Handlers);
7              
8             requires "kiokudb_upgrade_handlers_table";
9              
10 2     2   509 no warnings 'uninitialized';
  2         2  
  2         247  
11              
12             sub kiokudb_upgrade_handler {
13 26     26 0 42 my ( $class, $version ) = @_;
14              
15 26         92 my $table = $class->kiokudb_upgrade_handlers_table;
16              
17 26         66 return grep { defined } $table->{$version};
  26         128  
18             }
19              
20             # ex: set sw=4 et:
21              
22             __PACKAGE__
23              
24             __END__
25              
26             =pod
27              
28             =head1 NAME
29              
30             KiokuDB::Role::Upgrade::Handlers::Table - A role for classes
31              
32             =head1 SYNOPSIS
33              
34             with qw(KiokuDB::Role::Upgrade::Handlers::Table);
35              
36             use constant kiokudb_upgrade_handlers_table => {
37              
38             # like the individual entries in class_version_table
39              
40             "0.01" => "0.02",
41             "0.02" => sub {
42             ...
43             },
44             };
45              
46             =head1 DESCRIPTION
47              
48             This class lets you provide the version handling table as part of the class
49             definition, instead of as arguments to the L<KiokuDB> handle constructor.
50              
51             See L<KiokuDB::TypeMap::Entry::MOP> more details and
52             L<KiokuDB::Role::Upgrade::Data> for a lower level alternative.