def enhance_batch!(conn, record_batch)
      return record_batch if record_batch.nil? || record_batch.empty?

      copy_info = get_joined_table(
        conn, record_batch,
        :table_name  => "copy",
        :column_map  => settings['horizon.copy_map'],
        :join_clause => settings['horizon.copy_join_clause'],
        :public_only => (settings['horizon.public_only'].to_s == "true")
      ) if %w{all copies direct}.include? settings['horizon.include_holdings'].to_s



      item_info = get_joined_table(
        conn, record_batch,
        :table_name  => "item",
        :column_map  => settings['horizon.item_map'],
        :join_clause => settings['horizon.item_join_clause'],
        :public_only => (settings['horizon.public_only'].to_s == "true")
      ) if %w{all items direct}.include? settings['horizon.include_holdings'].to_s



      if item_info || copy_info
        record_batch.each do |record|
          id = record['001'].value.to_s
          record_copy_info = copy_info && copy_info[id]
          record_item_info = item_info && item_info[id]

          record_copy_info.each do |copy_row|
            field = MARC::DataField.new( settings["horizon.copy_tag"] )
            copy_row.each_pair do |subfield, value|
              field.append MARC::Subfield.new(subfield, value)
            end
            record.append field
          end if record_copy_info

          record_item_info.each do |item_row|
            field = MARC::DataField.new( settings["horizon.item_tag"] )
            item_row.each_pair do |subfield, value|
              field.append MARC::Subfield.new(subfield, value)
            end
            record.append field
          end if record_item_info && ((settings['horizon.include_holdings'].to_s != "direct") || record_copy_info.empty?)
        end
      end

      return record_batch
    end
def enhance_batch!(conn, record_batch)
      return record_batch if record_batch.nil? || record_batch.empty?

      copy_info = get_joined_table(
        conn, record_batch,
        :table_name  => "copy",
        :column_map  => settings['horizon.copy_map'],
        :join_clause => settings['horizon.copy_join_clause'],
        :public_only => (settings['horizon.public_only'].to_s == "true")
      ) if %w{all copies direct}.include? settings['horizon.include_holdings'].to_s



      item_info = get_joined_table(
        conn, record_batch,
        :table_name  => "item",
        :column_map  => settings['horizon.item_map'],
        :join_clause => settings['horizon.item_join_clause'],
        :public_only => (settings['horizon.public_only'].to_s == "true")
      ) if %w{all items direct}.include? settings['horizon.include_holdings'].to_s



      if item_info || copy_info
        record_batch.each do |record|
          id = record['001'].value.to_s
          record_copy_info = copy_info && copy_info[id]
          record_item_info = item_info && item_info[id]

          record_copy_info.each do |copy_row|
            field = MARC::DataField.new( settings["horizon.copy_tag"] )
            copy_row.each_pair do |subfield, value|
              field.append MARC::Subfield.new(subfield, value)
            end
            record.append field
          end if record_copy_info

          record_item_info.each do |item_row|
            field = MARC::DataField.new( settings["horizon.item_tag"] )
            item_row.each_pair do |subfield, value|
              field.append MARC::Subfield.new(subfield, value)
            end
            record.append field
          end if record_item_info && ((settings['horizon.include_holdings'].to_s != "direct") || record_copy_info.empty?)
        end
      end

      return record_batch
    end
Pass in an array of MARC::Records', adds fields for copy and item
 info if so configured. Returns record_batch so you can chain if you want.