Commit | Line | Data |
c5051351 |
1 | package SQL::Translator::Object::Constraint; |
abb2c327 |
2 | use namespace::autoclean; |
c5051351 |
3 | use Moose; |
109263d0 |
4 | use MooseX::Types::Moose qw(HashRef Str); |
e157d782 |
5 | use MooseX::AttributeHelpers; |
c0e05758 |
6 | use SQL::Translator::Types qw(Column); |
cc73c25e |
7 | extends 'SQL::Translator::Object'; |
c5051351 |
8 | |
109263d0 |
9 | has 'name' => ( |
44547961 |
10 | is => 'rw', |
11 | isa => Str, |
12 | required => 1 |
109263d0 |
13 | ); |
14 | |
15 | has 'columns' => ( |
44547961 |
16 | metaclass => 'Collection::Hash', |
17 | is => 'rw', |
18 | isa => HashRef[Column], |
19 | provides => { |
20 | exists => 'exists_column', |
21 | keys => 'column_ids', |
22 | get => 'get_column', |
23 | }, |
24 | curries => { |
25 | set => { |
26 | add_column => sub { |
27 | my ($self, $body, $column) = @_; |
28 | $self->$body($column->name, $column); |
29 | } |
30 | } |
31 | }, |
2e4bad4f |
32 | default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash }, |
109263d0 |
33 | ); |
34 | |
35 | has 'type' => ( |
44547961 |
36 | is => 'rw', |
37 | isa => Str, |
38 | required => 1 |
109263d0 |
39 | ); |
c5051351 |
40 | |
7aa485df |
41 | __PACKAGE__->meta->make_immutable; |
42 | |
c5051351 |
43 | 1; |