From: Justin Hunter Date: Wed, 19 Aug 2009 10:06:04 +0000 (-0700) Subject: add more attributes X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3fb92fdf02153d88fc25ee7011c249eb56f4fa26;p=dbsrgits%2FSQL-Translator-2.0-ish.git add more attributes --- diff --git a/lib/SQL/Translator/Object/Trigger.pm b/lib/SQL/Translator/Object/Trigger.pm index a1d1de9..2f8f442 100644 --- a/lib/SQL/Translator/Object/Trigger.pm +++ b/lib/SQL/Translator/Object/Trigger.pm @@ -1,7 +1,8 @@ use MooseX::Declare; class SQL::Translator::Object::Trigger { - use MooseX::Types::Moose qw(Str); - use SQL::Translator::Types qw(); + use MooseX::Types::Moose qw(ArrayRef HashRef Str); + use MooseX::AttributeHelpers; + use SQL::Translator::Types qw(Column); extends 'SQL::Translator::Object'; has 'name' => ( @@ -9,4 +10,51 @@ class SQL::Translator::Object::Trigger { isa => Str, required => 1 ); + + has 'columns' => ( + metaclass => 'Collection::Hash', + is => 'rw', + isa => HashRef[Column], + provides => { + exists => 'exists_column', + keys => 'column_ids', + values => 'get_columns', + get => 'get_column', + }, + curries => { + set => { + add_column => sub { + my ($self, $body, $column) = @_; + $self->$body($column->name, $column); + } + } + }, + default => sub { my %hash = (); tie %hash, 'Tie::IxHash'; return \%hash }, + ); + + has 'on_table' => ( + is => 'rw', + isa => Str, + required => 1 + ); + + has 'action' => ( + is => 'rw', + isa => Str + ); + + has 'perform_action_when' => ( + is => 'rw', + isa => Str, + required => 1 + ); + + has 'database_events' => ( + is => 'rw', + isa => ArrayRef, + required => 1 + ); + + method get_fields { return $self->get_columns } + method fields { return $self->column_ids } }