release 0.11016
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Role / BuildArgs.pm
CommitLineData
45595850 1package SQL::Translator::Role::BuildArgs;
4e43db0d 2
3=head1 NAME
4
5SQL::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
15This L<Moo::Role> wraps BUILDARGS to remove C<undef> constructor
16arguments for backwards compatibility with the old L<Class::Base>-based
17L<SQL::Translator::Schema::Object>.
18
19=cut
20
46ad748f 21use Moo::Role;
22
23around 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
341;