]> gitweb.michael.orlitzky.com - mailshears.git/blobdiff - lib/mv/mv_runner.rb
Factor out the description-message-building in the runners.
[mailshears.git] / lib / mv / mv_runner.rb
index 6da6f6d3bb7fd6311d6e27915d5c10d230f981f1..1fac09ef8c062026ee1bb6aaac49dd0e9386c26c 100644 (file)
@@ -2,10 +2,24 @@ require 'common/domain'
 require 'common/errors'
 require 'common/runner'
 
+# Perform the moving (renaming) of users/domains using {MvPlugin}s.
+#
 class MvRunner
   include Runner
 
-  def run(plugin, src, dst)
+  # Run *plugin* to move the user *src* to *dst*. 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 move.
+  #
+  # @param src [User] the source user to be moved.
+  #
+  # @param dst [User] the destination user being moved to.
+  #
+  def run(cfg, plugin, src, dst)
 
     if src.is_a?(Domain) or dst.is_a?(Domain) then
       msg = 'only users can be moved'
@@ -17,24 +31,10 @@ class MvRunner
       plugin.mv_user(src, dst)
       dst_description = plugin.describe(dst)
 
-      msg  = "Moved user #{src} "
-
-      # Only append the extra description if it's useful.
-      if not src_description.nil? and
-         not src_description.empty? and
-         not src_description == src.to_s() then
-        msg += "(#{src_description}) "
-      end
-
-      msg += "to #{dst}"
-
-      # Only append the extra description if it's useful.
-      if not dst_description.nil? and
-         not dst_description.empty? and
-         not dst_description == dst.to_s() then
-        msg += " (#{dst_description})"
-      end
-
+      msg  = "Moved user "
+      msg += add_description(src, src_description)
+      msg += " to "
+      msg += add_description(dst, dst_description)
       msg += "."
       report(plugin, msg)