X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FTranslator%2FSchema%2FProcedure.pm;h=97e55cb054768e7bd0fa61549c24bf01e2c2f0dd;hb=da93ce6850901652d43fa1033a1ea58fa82230b4;hp=0fd5c091ba8433290164ef96e7f0b79f62d3e56b;hpb=46ad748fcf9f976bb6ce2549f135023e3d66b2a8;p=dbsrgits%2FSQL-Translator.git diff --git a/lib/SQL/Translator/Schema/Procedure.pm b/lib/SQL/Translator/Schema/Procedure.pm index 0fd5c09..97e55cb 100644 --- a/lib/SQL/Translator/Schema/Procedure.pm +++ b/lib/SQL/Translator/Schema/Procedure.pm @@ -28,18 +28,14 @@ stored procedures (and possibly other pieces of nameable SQL code?). =cut use Moo; -use SQL::Translator::Utils qw(parse_list_arg ex2err); +use SQL::Translator::Utils qw(ex2err); +use SQL::Translator::Role::ListAttr; use SQL::Translator::Types qw(schema_obj); -use List::MoreUtils qw(uniq); +use Sub::Quote qw(quote_sub); -with qw( - SQL::Translator::Schema::Role::BuildArgs - SQL::Translator::Schema::Role::Extra - SQL::Translator::Schema::Role::Error - SQL::Translator::Schema::Role::Compare -); +extends 'SQL::Translator::Schema::Object'; -our $VERSION = '1.59'; +our $VERSION = '1.60'; =head2 new @@ -63,20 +59,7 @@ Gets and set the parameters of the stored procedure. =cut -has parameters => ( - is => 'rw', - default => sub { [] }, - coerce => sub { [uniq @{parse_list_arg($_[0])}] }, -); - -around parameters => sub { - my $orig = shift; - my $self = shift; - my $fields = parse_list_arg( @_ ); - $self->$orig($fields) if @$fields; - - return wantarray ? @{ $self->$orig } : $self->$orig; -}; +with ListAttr parameters => ( uniq => 1 ); =head2 name @@ -87,7 +70,7 @@ Get or set the procedure's name. =cut -has name => ( is => 'rw', default => sub { '' } ); +has name => ( is => 'rw', default => quote_sub(q{ '' }) ); =head2 sql @@ -98,7 +81,7 @@ Get or set the procedure's SQL. =cut -has sql => ( is => 'rw', default => sub { '' } ); +has sql => ( is => 'rw', default => quote_sub(q{ '' }) ); =head2 order @@ -121,7 +104,7 @@ Get or set the owner of the procedure. =cut -has owner => ( is => 'rw', default => sub { '' } ); +has owner => ( is => 'rw', default => quote_sub(q{ '' }) ); =head2 comments @@ -135,8 +118,8 @@ Get or set the comments on a procedure. has comments => ( is => 'rw', - coerce => sub { ref($_[0]) eq 'ARRAY' ? $_[0] : [$_[0]] }, - default => sub { [] }, + coerce => quote_sub(q{ ref($_[0]) eq 'ARRAY' ? $_[0] : [$_[0]] }), + default => quote_sub(q{ [] }), ); around comments => sub { @@ -161,7 +144,7 @@ Get or set the procedures's schema object. =cut -has schema => ( is => 'rw', isa => schema_obj('Schema') ); +has schema => ( is => 'rw', isa => schema_obj('Schema'), weak_ref => 1 ); around schema => \&ex2err; @@ -202,11 +185,6 @@ around equals => sub { return 1; }; -sub DESTROY { - my $self = shift; - undef $self->{'schema'}; # destroy cyclical reference -} - # Must come after all 'has' declarations around new => \&ex2err;