class Atmosphere::MigrationJobDecorator < Draper::Decorator
  delegate_all

  def appliance_type_name
    if object.appliance_type
      object.appliance_type.name
    else
      'unknown'
    end
  end

  def virtual_machine_template_name
    if object.virtual_machine_template
      object.virtual_machine_template.name
    else
      'unknown'
    end
  end

  def virtual_machine_template_id_at_site
    if object.virtual_machine_template
      object.virtual_machine_template.id_at_site
    else
      'unknown'
    end
  end

  def compute_site_source_name
    if object.compute_site_source
      object.compute_site_source.name
    else
      'unknown'
    end
  end

  def compute_site_destination_name
    if object.compute_site_destination
      object.compute_site_destination.name
    else
      'unknown'
    end
  end

  def status_last_line
    if object.status
      object.status.lines.last
    else
      'unknown'
    end
  end
end

class Atmosphere::MigrationJobDecorator < Draper::Decorator
  delegate_all

  def appliance_type_name
    at = object.appliance_type
    at ? at.name : 'unknown'
  end

  def virtual_machine_template_name
    vmt = object.virtual_machine_template
    vmt ? vmt.name : 'unknown'
  end

  def virtual_machine_template_id_at_site
    vmt = object.virtual_machine_template
    vmt ? vmt.id_at_site : 'unknown'
  end

  def compute_site_source_name
    css = object.compute_site_source
    css ? css.name : 'unknown'
  end

  def compute_site_destination_name
    csd = object.compute_site_destination
    csd ? csd.name : 'unknown'
  end

  def status_last_line
    s = object.status
    s ? s.lines.last : 'unknown'
  end
end

Fix due to comments, use ?: elvis operator
Fix due to comments, use ?: elvis operator
