class HammerCLIForeman::Output::Formatters::SingleReferenceFormatter

Public Instance Methods

format(resource, field_params={}) click to toggle source
# File lib/hammer_cli_foreman/output/formatters.rb, line 10
def format(resource, field_params={})
  return "" if resource.nil?

  key = field_params[:key]

  id_key = "#{key}_id"
  name_key = "#{key}_name"

  name = resource[name_key.to_sym] || resource[name_key]
  id = resource[id_key.to_sym] || resource[id_key]

  context = field_params[:context] || {}

  out = "#{name}"
  out += " (id: #{id})" if context[:show_ids] && id
  out
end
tags() click to toggle source
# File lib/hammer_cli_foreman/output/formatters.rb, line 6
def tags
  [:flat]
end