| 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<Moo::Role> wraps BUILDARGS to remove C<undef> constructor | ||||||||||
| 16 | arguments for backwards compatibility with the old L<Class::Base>-based | ||||||||||
| 17 | L<SQL::Translator::Schema::Object>. | ||||||||||
| 18 | |||||||||||
| 19 | =cut | ||||||||||
| 20 | |||||||||||
| 21 | 77 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | 3406 | ▶ | around BUILDARGS => sub { | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 24 | 3406 | my $orig = shift; | |||||||||
| 25 | 3406 | my $self = shift; | |||||||||
| 26 | 3406 | my $args = $self->$orig(@_); | |||||||||
| 27 | |||||||||||
| 28 | 3406 | foreach my $arg (keys %{$args}) { | |||||||||
| 29 | 20662 | ▶ | delete $args->{$arg} unless defined($args->{$arg}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | } | ||||||||||
| 31 | 3406 | return $args; | |||||||||
| 32 | 77 | }; | |||||||||
| 33 | |||||||||||
| 34 | 77 | 1; | |||||||||