use $pdata instead of $tdata for procedure info
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Index.pm
1 use MooseX::Declare;
2 class SQL::Translator::Object::Index extends SQL::Translator::Object {
3     use MooseX::Types::Moose qw(HashRef Str);
4     use MooseX::MultiMethods;
5     use SQL::Translator::Types qw(Column Table);
6
7     has 'table' => (
8         is => 'rw',
9         isa => Table,
10         weak_ref => 1,
11     );
12     
13     has 'name' => (
14         is => 'rw',
15         isa => Str,
16         required => 1
17     );
18
19     has 'columns' => (
20         traits => ['Hash'],
21         is => 'rw',
22         isa => HashRef[Column],
23         handles => {
24             exists_column => 'exists',
25             column_ids    => 'keys',
26             get_columns   => 'values',
27             get_column    => 'get',
28             add_column    => 'set',
29             clear_columns => 'clear',
30         },
31         default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
32     );
33
34     has 'type' => (
35         is => 'rw',
36         isa => Str,
37         required => 1,
38         default => 'NORMAL',
39     );
40
41     around add_column(Column $column) { $self->$orig($column->name, $column) }
42
43     method is_valid { $self->table && scalar $self->get_columns ? 1 : undef }
44 }