2 class SQL::Translator {
3 use MooseX::Types::Moose qw(Str);
5 use SQL::Translator::Types qw(DBIHandle Parser Producer);
25 handles => [ qw(parse) ],
32 handles => [ qw(produce) ],
38 predicate => 'has_dbh',
44 predicate => 'has_ddl',
47 method _build__parser {
48 my $class = 'SQL::Translator::Parser';
50 Class::MOP::load_class($class);
54 $parser = $class->new({ dbh => $self->dbh });
55 } elsif ($self->has_ddl) {
56 $parser = $class->new({ filename => $self->filename, type => $self->parser });
58 die "dbh or filename is required!";
64 method _build__producer {
65 my $class = 'SQL::Translator::Producer';
66 my $role = $class . '::' . $self->producer;
68 Class::MOP::load_class($class);
69 try { Class::MOP::load_class($role) } catch ($e) { $role = $class . '::SQL::' . $self->producer; Class::MOP::load_class($role) }
71 my $producer = $class->new({ schema => $self->parse });
72 $role->meta->apply($producer);