Commit | Line | Data |
45595850 |
1 | package SQL::Translator::Role::BuildArgs; |
4e43db0d |
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 | |
46ad748f |
21 | use Moo::Role; |
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; |