comments cannot be set in the constructor, must use external method
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Trigger.pm
CommitLineData
4f4fd192 1use MooseX::Declare;
ebf2721d 2class SQL::Translator::Object::Trigger extends SQL::Translator::Object {
c53f9843 3 use MooseX::Types::Moose qw(Any ArrayRef HashRef Str);
3fb92fdf 4 use MooseX::AttributeHelpers;
5 use SQL::Translator::Types qw(Column);
4f4fd192 6
7 has 'name' => (
8 is => 'ro',
9 isa => Str,
10 required => 1
11 );
3fb92fdf 12
13 has 'columns' => (
14 metaclass => 'Collection::Hash',
15 is => 'rw',
16 isa => HashRef[Column],
17 provides => {
18 exists => 'exists_column',
19 keys => 'column_ids',
20 values => 'get_columns',
21 get => 'get_column',
51700db2 22 set => 'add_column',
3fb92fdf 23 },
24 default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
25 );
26
27 has 'on_table' => (
28 is => 'rw',
29 isa => Str,
30 required => 1
31 );
32
33 has 'action' => (
34 is => 'rw',
c53f9843 35 isa => Any
3fb92fdf 36 );
37
38 has 'perform_action_when' => (
39 is => 'rw',
40 isa => Str,
41 required => 1
42 );
43
44 has 'database_events' => (
45 is => 'rw',
46 isa => ArrayRef,
47 required => 1
48 );
49
51700db2 50 around add_column(Column $column) { $self->$orig($column->name, $column) }
51
6b4be44b 52 method get_fields { $self->get_columns }
53 method fields { $self->column_ids }
4f4fd192 54}