From: Justin Hunter Date: Tue, 9 Feb 2010 06:23:05 +0000 (-0800) Subject: long awaited BUILDARGS to help with comments/options/extra X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=66cf0711f06342d378e5633413f38ada45ad9496;p=dbsrgits%2FSQL-Translator-2.0-ish.git long awaited BUILDARGS to help with comments/options/extra --- diff --git a/lib/SQL/Translator/Object.pm b/lib/SQL/Translator/Object.pm index 3091d79..67d9bed 100644 --- a/lib/SQL/Translator/Object.pm +++ b/lib/SQL/Translator/Object.pm @@ -58,4 +58,14 @@ class SQL::Translator::Object with SQL::Translator::Object::Compat { multi method extra(Str $extra) { $self->get_extra($extra) } multi method extra(HashRef $extra) { $self->add_extra($_, $extra->{$_}) for keys %$extra; $self->extra } multi method extra { wantarray ? %{$self->_extra} : $self->_extra } + + around BUILDARGS(ClassName $self: @args) { + my $args = $self->$orig(@args); + + $args->{_comments} = delete $args->{comments} || []; + $args->{_options} = delete $args->{options} || []; + $args->{_extra} = delete $args->{extra} || {}; + + return $args; + } }