move from no Moose[::Role] to use namespace::autoclean
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Table.pm
1 package SQL::Translator::Object::Table;
2 use namespace::autoclean;
3 use Moose;
4 use MooseX::Types::Moose qw(HashRef Str);
5 use MooseX::AttributeHelpers;
6 use SQL::Translator::Types qw(Column Constraint Index Schema);
7 use SQL::Translator::Object::Schema;
8 extends 'SQL::Translator::Object';
9
10 has 'name' => (
11   is => 'rw',
12   isa => Str,
13   required => 1
14 );
15
16 has 'columns' => (
17   metaclass => 'Collection::Hash',
18   is => 'rw',
19   isa => HashRef[Column],
20   provides => {
21     exists => 'exists_column',
22     keys   => 'column_ids',
23     get    => 'get_column',
24   },
25   curries => { set => { add_column => sub { my ($self, $body, $column) = @_; $self->$body($column->name, $column); } } },
26   default => sub { {} },
27   required => 0
28 );
29
30 has 'indexes' => (
31   metaclass => 'Collection::Hash',
32   is => 'rw',
33   isa => HashRef[Index],
34   provides => {
35     exists => 'exists_index',
36     keys   => 'index_ids',
37     get    => 'get_index',
38   },
39   curries => { set => { add_index => sub { my ($self, $body, $index) = @_; $self->$body($index->name, $index); } } },
40   default => sub { {} },
41   required => 0
42 );
43
44 has 'constraints' => (
45   metaclass => 'Collection::Hash',
46   is => 'rw',
47   isa => HashRef[Constraint],
48   provides => {
49     exists => 'exists_constraint',
50     keys   => 'constraint_ids',
51     get    => 'get_constraint',
52   },
53   curries => { set => { add_constraint => sub { my ($self, $body, $constraint) = @_; $self->$body($constraint->name, $constraint); } } },
54   default => sub { {} },
55   required => 0
56 );
57
58 __PACKAGE__->meta()->make_immutable;
59
60 1;