use Moo;
use SQL::Translator::Schema::Constants;
-use SQL::Translator::Utils qw(parse_list_arg ex2err throw);
+use SQL::Translator::Utils qw(ex2err throw);
+use SQL::Translator::Role::ListAttr;
use SQL::Translator::Types qw(schema_obj);
-use List::MoreUtils qw(uniq);
extends 'SQL::Translator::Schema::Object';
=cut
-has fields => (
- is => 'rw',
- default => sub { [] },
- coerce => sub { [uniq @{parse_list_arg($_[0])}] },
-);
-
-around fields => 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 fields => ( uniq => 1 );
sub is_valid {
=cut
-has options => (
- is => 'rw',
- default => sub { [] },
- coerce => \&parse_list_arg,
-);
-
-around options => sub {
- my $orig = shift;
- my $self = shift;
- my $options = parse_list_arg( @_ );
-
- push @{ $self->$orig }, @$options;
-
- return wantarray ? @{ $self->$orig } : $self->$orig;
-};
+with ListAttr options => ();
=head2 table