You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: hardware.rb
    path of file: ./repos/manageiq/app/models
    
    the code of the file until where you have to start completion: class Hardware < ApplicationRecord
  belo
    
  def self.add_elements(parent, xmlNode)
    _log.info("Adding Hardware XML elements for VM[id]=[#{parent.id}] from XML doc [#{xmlNode.root.name}]")
    parent.hardware = Hardware.new if parent.hardware.nil?
    # Record guest_devices so we can delete any removed items.
    deletes = {:gd => [], :disk => []}

    # Excluding ethernet devices from deletes because the refresh is the master of the data and it will handle the deletes.
    deletes[:gd] = parent.hardware.guest_devices
                   .where.not(:device_type => "ethernet")
                   .select(:id, :device_type, :location, :address)
                   .collect { |rec| [rec.id, [rec.device_type, rec.location, rec.address]] }

    if parent.vendor == "redhat"
      deletes[:disk] = parent.hardware.disks.select(:id, :device_type, :location)
                     .collect { |rec| [rec.id, [rec.device_type, "0:#{rec.location}"]] }
    else
      deletes[:disk] = parent.hardware.disks.select(:id, :device_type, :location)
                     .collect { |rec| [rec.id, [rec.device_type, rec.location]] }
    end

    xmlNode.root.each_recursive do |e|
      begin
        parent.hardware.send(:"m_#{e.name}", parent, e, deletes) if parent.hardware.respond_to?(:"m_#{e.name}")
      rescue => err
        _log.warn(err.to_s)
      end
    end