From: Justin Hunter Date: Wed, 26 Aug 2009 04:33:49 +0000 (-0700) Subject: add extra behavior to parameters attribute X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0c86c13af347096645b4814adfa8cc86a8fbb73f;p=dbsrgits%2FSQL-Translator-2.0-ish.git add extra behavior to parameters attribute --- diff --git a/lib/SQL/Translator/Object/Procedure.pm b/lib/SQL/Translator/Object/Procedure.pm index 065062b..006f37a 100644 --- a/lib/SQL/Translator/Object/Procedure.pm +++ b/lib/SQL/Translator/Object/Procedure.pm @@ -1,6 +1,8 @@ use MooseX::Declare; class SQL::Translator::Object::Procedure extends SQL::Translator::Object { use MooseX::Types::Moose qw(ArrayRef Str); + use MooseX::AttributeHelpers; + use MooseX::MultiMethods; has 'name' => ( is => 'rw', @@ -14,9 +16,17 @@ class SQL::Translator::Object::Procedure extends SQL::Translator::Object { required => 1 ); - has 'parameters' => ( + has '_parameters' => ( + metaclass => 'Collection::Array', is => 'rw', isa => ArrayRef, + provides => { + push => 'add_parameter', + pop => 'remove_last_parameter', + }, + default => sub { [] }, + auto_deref => 1, + ); has 'owner' => ( @@ -24,4 +34,8 @@ class SQL::Translator::Object::Procedure extends SQL::Translator::Object { isa => Str, required => 1 ); + + multi method parameters(Str $parameter) { $self->add_parameter($parameter) } + multi method parameters(ArrayRef $parameter) { $self->add_parameter($parameter) } + multi method parameters(Any $) { wantarray ? @{$self->_parameters} : $self->_parameters } }