move comments down to the base Object
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Constraint.pm
CommitLineData
4f4fd192 1use MooseX::Declare;
2class SQL::Translator::Object::Constraint {
b750d2f1 3 use MooseX::Types::Moose qw(ArrayRef Bool HashRef Maybe Str);
4f4fd192 4 use MooseX::AttributeHelpers;
5 use SQL::Translator::Types qw(Column);
6 extends 'SQL::Translator::Object';
7
8 has 'name' => (
9 is => 'rw',
526e74d1 10 isa => Maybe[Str],
4f4fd192 11 required => 1
12 );
13
14 has 'columns' => (
15 metaclass => 'Collection::Hash',
16 is => 'rw',
17 isa => HashRef[Column],
18 provides => {
19 exists => 'exists_column',
20 keys => 'column_ids',
526e74d1 21 values => 'get_columns',
4f4fd192 22 get => 'get_column',
51700db2 23 set => 'add_column',
4f4fd192 24 },
25 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
26 );
27
28 has 'type' => (
29 is => 'rw',
30 isa => Str,
31 required => 1
32 );
526e74d1 33
b750d2f1 34 has 'deferrable' => (
35 is => 'rw',
36 isa => Bool,
37 default => 0
38 );
39
40 has 'expression' => (
41 is => 'rw',
42 isa => Str,
43 );
44
45 has 'options' => (
46 is => 'rw',
47 isa => ArrayRef,
48 auto_deref => 1
49 );
50
51 has 'extra' => (
52 is => 'rw',
53 isa => HashRef,
54 auto_deref => 1,
55 );
56
51700db2 57 around add_column(Column $column) { $self->$orig($column->name, $column) }
58
526e74d1 59 method get_fields { return $self->get_columns }
60 method fields { return $self->column_ids }
b750d2f1 61 method field_names { return $self->column_ids }
62
63 method match_type { }
4f4fd192 64}