move backcompat into Compat.pm and apply the role to Object.pm
[dbsrgits/SQL-Translator-2.0-ish.git] / lib / SQL / Translator / Object / Trigger.pm
1 use MooseX::Declare;
2 class SQL::Translator::Object::Trigger extends SQL::Translator::Object {
3     use MooseX::Types::Moose qw(Any ArrayRef HashRef Str);
4     use SQL::Translator::Types qw(Column);
5     
6     has 'name' => (
7         is => 'ro',
8         isa => Str,
9         required => 1
10     );
11
12     has 'columns' => (
13         traits => ['Hash'],
14         is => 'rw',
15         isa => HashRef[Column],
16         handles => {
17             exists_column => 'exists',
18             column_ids    => 'keys',
19             get_columns   => 'values',
20             get_column    => 'get',
21             add_column    => 'set',
22         },
23         default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash },
24     );
25
26     has 'on_table' => (
27         is => 'rw', 
28         isa => Str,
29         required => 1
30     );
31
32     has 'action' => (
33         is => 'rw',
34         isa => Any
35     );
36
37     has 'perform_action_when' => (
38         is => 'rw',
39         isa => Str,
40         required => 1
41     );
42
43     has 'database_events' => (
44         is => 'rw',
45         isa => ArrayRef,
46         required => 1
47     );
48
49     around add_column(Column $column) { $self->$orig($column->name, $column) }
50 }