[Rt-commit] r5757 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Sat Aug 12 01:19:16 EDT 2006


Author: ruz
Date: Sat Aug 12 01:19:15 2006
New Revision: 5757

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder.pm

Log:
 r3641 at cubic-pc:  cubic | 2006-08-12 06:06:44 +0400
 Shredder::AddDumpPlugin
 * add Object argument, so it's possible to use pre-loaded plugin
 * argument 'Arguments' is optional now


Modified: rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder.pm
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder.pm	(original)
+++ rt/branches/3.7-EXPERIMENTAL/lib/RT/Shredder.pm	Sat Aug 12 01:19:15 2006
@@ -595,16 +595,21 @@
 
 sub AddDumpPlugin {
     my $self = shift;
-    my %args = ( Name => 'SQLDump', Arguments => {}, @_ );
+    my %args = ( Object => undef, Name => 'SQLDump', Arguments => undef, @_ );
 
-    my $plugin = RT::Shredder::Plugin->new;
-    my( $status, $msg ) = $plugin->LoadByName( $args{'Name'} );
-    die "Couldn't load dump plugin: $msg\n" unless $status;
-    die "Plugin '$args{'Name'}' is not of correct type"
-        unless $plugin->Type eq 'dump';
+    my $plugin = $args{'Object'};
+    unless ( $plugin ) {
+        require RT::Shredder::Plugin;
+        $plugin = RT::Shredder::Plugin->new;
+        my( $status, $msg ) = $plugin->LoadByName( $args{'Name'} );
+        die "Couldn't load dump plugin: $msg\n" unless $status;
+    }
+    die "Plugin is not of correct type" unless lc $plugin->Type eq 'dump';
 
-    ($status, $msg) = $plugin->TestArgs( %{ $args{'Arguments'} } );
-    die "Couldn't set plugin args: $msg\n" unless $status;
+    if ( my $pargs = $args{'Arguments'} ) {
+        my ($status, $msg) = $plugin->TestArgs( %$pargs );
+        die "Couldn't set plugin args: $msg\n" unless $status;
+    }
 
     push @{ $self->{'opt'}{'dump_plugins'} ||= [] }, $plugin;
 


More information about the Rt-commit mailing list