如何摆脱这种重复if conditional
?
def set_caption(result)
if result.respond_to?(:app_name)
content_tag(:div, result.type_name, class: 'type-name') +
content_tag(:div, result.app_name, class: 'app-name')
else
content_tag(:div, result.type_name, class: 'type-name')
end
end