move to MooseX::Declare extends style
[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 MooseX::AttributeHelpers;
5     use SQL::Translator::Types qw(Column);
6     
7     has 'name' => (
8         is => 'ro',
9         isa => Str,
10         required => 1
11     );
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',
22             set    => 'add_column',
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',
35         isa => Any
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
50     around add_column(Column $column) { $self->$orig($column->name, $column) }
51
52     method get_fields { $self->get_columns }
53     method fields { $self->column_ids }
54 }