def migrate(&block)
      unless block_given? then
        return migrate { |tgt, row| tgt }
      end
      # If there is an extract, then wrap the migration in an extract
      # writer block.
      if @extract then
        if String === @extract then
          logger.debug { "Opening migration extract #{@extract}..." }
          FileUtils::mkdir_p(File.dirname(@extract))
          if @extract_hdrs then
            logger.debug { "Migration extract headers: #{@extract_hdrs.join(', ')}." }
            CsvIO.open(@extract, :mode => 'w', :headers => @extract_hdrs) do |io|
              @extract = io
              return migrate(&block)
            end
          else
            File.open(@extract, 'w') do |io|
              @extract = io
              return migrate(&block)
            end
          end
        end
        # Copy the extract into a local variable and clear the extract i.v.
        # prior to a recursive call with an extract writer block.
        io, @extract = @extract, nil
        return migrate do |tgt, row|
          res = yield(tgt, row)
          tgt.extract(io)
          res
        end
      end
      begin
        migrate_rows(&block)
      ensure
        @rejects.close if @rejects
        remove_migration_methods
      end
    end
def migrate(&block)
      unless block_given? then
        return migrate { |tgt, row| tgt }
      end
      # If there is an extract, then wrap the migration in an extract
      # writer block.
      if @extract then
        if String === @extract then
          logger.debug { "Opening migration extract #{@extract}..." }
          FileUtils::mkdir_p(File.dirname(@extract))
          if @extract_hdrs then
            logger.debug { "Migration extract headers: #{@extract_hdrs.join(', ')}." }
            CsvIO.open(@extract, :mode => 'w', :headers => @extract_hdrs) do |io|
              @extract = io
              return migrate(&block)
            end
          else
            File.open(@extract, 'w') do |io|
              @extract = io
              return migrate(&block)
            end
          end
        end
        # Copy the extract into a local variable and clear the extract i.v.
        # prior to a recursive call with an extract writer block.
        io, @extract = @extract, nil
        return migrate do |tgt, row|
          res = yield(tgt, row)
          tgt.extract(io)
          res
        end
      end
      begin
        migrate_rows(&block)
      ensure
        @rejects.close if @rejects
        remove_migration_methods
      end
    end
Creates a new Migrator from the given options.

 @param [{Symbol => Object}] opts the migration options
 @option opts [Class] :target the required target domain class
 @option opts [<String>, String] :mapping the required input field => caTissue attribute mapping file(s)
 @option opts [String, Migration::Reader] :input the required input file name or an adapter which
   implements the {Migration::Reader} methods
 @option opts [<String>, String] :defaults the optional caTissue attribute => value default mapping file(s)
 @option opts [<String>, String] :filters the optional caTissue attribute input value => caTissue value filter file(s)
 @option opts [<String>, String] :shims the optional shim file(s) to load
 @option opts [String] :unique the optional flag which ensures that migrator calls the +uniquify+ method on
   those migrated objects whose class includes the +Unique+ module
 @option opts [String] :create the optional flag indicating that existing target objects are ignored
 @option opts [String] :bad the optional invalid record file
 @option opts [String, IO] :extract the optional extract file or object that responds to +<<+
 @option opts [<String>] :extract_headers the optional extract CSV field headers
 @option opts [Integer] :from the optional starting source record number to process
 @option opts [Integer] :to the optional ending source record number to process
 @option opts [Boolean] :quiet the optional flag which suppress output messages
 @option opts [Boolean] :verbose the optional flag to print the migration progress
 Imports this migrator's CSV file and calls the given block on each migrated target
 domain object. If no block is given, then this method returns an array of the
 migrated target objects.

 @yield [target, row] operates on the migration target
 @yieldparam [Resource] target the migrated target domain object
 @yieldparam [{Symbol => Object}] row the migration source record