Bumping version to 1.60
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Schema / Procedure.pm
index 0fd5c09..97e55cb 100644 (file)
@@ -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;