add in role I forget
Arthur Axel 'fREW' Schmidt [Wed, 24 Feb 2010 04:57:54 +0000 (22:57 -0600)]
add predicate for backup_directory

lib/DBIx/Class/DeploymentHandler.pm
lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm [new file with mode: 0644]

index c67fb92..c40b5d3 100644 (file)
@@ -40,6 +40,7 @@ has upgrade_directory => (
 has backup_directory => (
   isa => 'Str',
   is  => 'ro',
+  predicate  => 'has_backup_directory',
 );
 
 has storage => (
diff --git a/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm b/lib/DBIx/Class/DeploymentHandler/WithSqltDeployMethod.pm
new file mode 100644 (file)
index 0000000..ab0dc76
--- /dev/null
@@ -0,0 +1,37 @@
+package DBIx::Class::DeploymentHandler::WithSqltDeployMethod;
+use Moose::Role;
+
+use DBIx::Class::DeploymentHandler::SqltDeployMethod;
+
+use Carp 'carp';
+
+has deploy_method => (
+  isa => 'DBIx::Class::DeploymentHandler::SqltDeployMethod',
+  is  => 'ro',
+  lazy_build => 1,
+  handles => [qw{
+    deployment_statements
+        deploy
+        create_install_ddl
+        create_update_ddl
+        create_ddl_dir
+        upgrade_single_step
+  }],
+);
+
+sub _build_deploy_method {
+       my $self = shift;
+       my $args = {
+               schema            => $self->schema,
+               databases         => $self->databases,
+               upgrade_directory => $self->upgrade_directory,
+               sqltargs          => $self->sqltargs,
+               storage           => $self->storage,
+               do_backup         => $self->do_backup,
+       };
+       $args->{backup_directory} = $self->backup_directory
+               if $self->has_backup_directory;
+       DBIx::Class::DeploymentHandler::SqltDeployMethod->new($args);
+}
+
+1;