From: Justin Hunter Date: Wed, 29 Jul 2009 15:07:37 +0000 (-0700) Subject: apply ddl parser role X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=eba3827bf054055f18991bcddc328867fb5d8f15;p=dbsrgits%2FSQL-Translator-2.0-ish.git apply ddl parser role --- diff --git a/lib/SQL/Translator/Parser.pm b/lib/SQL/Translator/Parser.pm index 1075a1f..9d443c4 100644 --- a/lib/SQL/Translator/Parser.pm +++ b/lib/SQL/Translator/Parser.pm @@ -6,13 +6,18 @@ class SQL::Translator::Parser { my $apply_role_dbi = sub { my $self = shift; - my $class = __PACKAGE__ . '::DBI'; - Class::MOP::load_class($class); - $class->meta->apply($self); + my $role = __PACKAGE__ . '::DBI'; + Class::MOP::load_class($role); + $role->meta->apply($self); $self->_subclass(); }; - my $apply_role_ddl = sub { }; + my $apply_role_ddl = sub { + my $self = shift; + my $role = __PACKAGE__ . '::DDL::' . $self->type; + Class::MOP::load_class($role); + $role->meta->apply($self); + }; has 'dbh' => ( isa => DBIHandle, @@ -28,6 +33,11 @@ class SQL::Translator::Parser { trigger => $apply_role_ddl, ); + has 'type' => ( + isa => Str, + is => 'ro', + ); + method parse { my $schema = Schema->new({ name => $self->schema_name }); $self->_add_tables($schema);