File Coverage

blib/lib/SQL/Translator/Role/BuildArgs.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             package SQL::Translator::Role::BuildArgs;
2              
3             =head1 NAME
4              
5             SQL::Translator::Role::BuildArgs - Remove undefined constructor arguments
6              
7             =head1 SYNOPSIS
8              
9             package Foo;
10             use Moo;
11             with qw(SQL::Translator::Role::BuildArgs);
12              
13             =head1 DESCRIPTION
14              
15             This L wraps BUILDARGS to remove C constructor
16             arguments for backwards compatibility with the old L-based
17             L.
18              
19             =cut
20              
21 74     74   37830 use Moo::Role;
  74         260  
  74         408  
22              
23             around BUILDARGS => sub {
24             my $orig = shift;
25             my $self = shift;
26             my $args = $self->$orig(@_);
27              
28             foreach my $arg (keys %{$args}) {
29             delete $args->{$arg} unless defined($args->{$arg});
30             }
31             return $args;
32             };
33              
34             1;