Parent

Methods

Class/Module Index [+]

Quicksearch

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] || {}

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

[Validate]

Generated with the Darkfish Rdoc Generator 2.