Commit | Line | Data |
4f4fd192 |
1 | use MooseX::Declare; |
ebf2721d |
2 | class SQL::Translator::Object::Trigger extends SQL::Translator::Object { |
c53f9843 |
3 | use MooseX::Types::Moose qw(Any ArrayRef HashRef Str); |
3fb92fdf |
4 | use SQL::Translator::Types qw(Column); |
4f4fd192 |
5 | |
6 | has 'name' => ( |
7 | is => 'ro', |
8 | isa => Str, |
9 | required => 1 |
10 | ); |
3fb92fdf |
11 | |
12 | has 'columns' => ( |
28bd628e |
13 | traits => ['Hash'], |
3fb92fdf |
14 | is => 'rw', |
15 | isa => HashRef[Column], |
28bd628e |
16 | handles => { |
17 | exists_column => 'exists', |
18 | column_ids => 'keys', |
19 | get_columns => 'values', |
20 | get_column => 'get', |
21 | add_column => 'set', |
452c34e6 |
22 | clear_columns => 'clear', |
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) } |
4f4fd192 |
51 | } |