]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/rm/rm_runner.rb
lib,test: replace connection query() method with sync_exec{,_params}.
[mailshears.git] / lib / rm / rm_runner.rb
index 2df8410c5ea9d6d3d65d2565ec9cc00552d7b1f0..1c2d344475e27d3f763553d15dfbbfb37fbe4d40 100644 (file)
@@ -1,32 +1,46 @@
 require 'common/errors'
 require 'common/runner'
 
+# Perform the removal of users/domains using {RmPlugin}s.
+#
 class RmRunner
   include Runner
 
-  def run(plugin, *targets)
+  # Run *plugin* to remove the users/domains in *targets*. The method
+  # signature includes the unused *cfg* for consistency with the
+  # runners that do need a {Configuration}.
+  #
+  # @param cfg [Configuration] unused.
+  #
+  # @param plugin [Class] plugin class that will perform the removal.
+  #
+  # @param targets [Array<User,Domain>] the users and domains to be
+  #   removed.
+  #
+  def run(cfg, plugin, *targets)
     targets.each do |target|
       remove_target(plugin, target)
     end
   end
 
-  private;
 
+  protected;
+
+  # Remove *target* using *plugin*. This operation is separate from
+  # the <tt>run()</tt> method so that it can be accessed by the prune
+  # runner.
+  #
+  # @param plugin [RmPlugin] the plugin that will remove the *target*.
+  #
+  # @param target [User,Domain] the user or domain to remove.
+  #
   def remove_target(plugin, target)
-    # Wrap the "remove this thing" operation so that it can be reused
-    # in the prine plugin.
     target_description = plugin.describe(target)
 
     begin
-      plugin.delete(target)
-      msg =  "Removed #{target.class.to_s().downcase()} #{target}"
-
-      # Only append the extra description if it's useful.
-      if not target_description.nil? and
-         not target_description.empty? and
-         not target_description == target.to_s() then
-        msg += " (#{target_description})"
-      end
+      plugin.remove(target)
+      msg =  "Removed #{target.class.to_s().downcase()} "
+      msg += add_description(target, target_description)
       msg += '.'
 
       report(plugin, msg)