From: Justin Hunter Date: Thu, 2 Jul 2009 07:32:37 +0000 (-0700) Subject: quasi-factory X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d6201a5e1927d50e5521cebba3200fe81479727c;p=dbsrgits%2FSQL-Translator-2.0-ish.git quasi-factory --- diff --git a/lib/SQL/Translator/Parser.pm b/lib/SQL/Translator/Parser.pm index ff055b5..4f4aa3f 100644 --- a/lib/SQL/Translator/Parser.pm +++ b/lib/SQL/Translator/Parser.pm @@ -1,5 +1,43 @@ package SQL::Translator::Parser; use Moose; -extends 'SQL::Translator'; +use MooseX::Types::Moose qw(Str); +use SQL::Translator::Types qw(DBIHandle); +#extends 'SQL::Translator'; +my $apply_role_dbi = sub { + my $self = shift; + my $class = __PACKAGE__ . '::DBI'; + Class::MOP::load_class($class); + $class->meta->apply($self); + $self->_subclass(); +}; + +my $apply_role_ddl = sub { }; + +has 'dbh' => ( + isa => DBIHandle, + is => 'ro', + predicate => 'has_dbh', + trigger => $apply_role_dbi, +); + +has 'ddl' => ( + isa => Str, + is => 'ro', + predicate => 'has_ddl', + trigger => $apply_role_ddl, +); + +sub BUILD {} + +after BUILD => sub { + my $self = shift; + my $schema = SQL::Translator::Object::Schema->new({ name => $self->schema_name }); + $self->_add_tables($schema); + use Data::Dumper; + print Dumper($schema); +}; + +no Moose; +__PACKAGE__->meta->make_immutable; 1;