Class: Fields::SingleReference

Inherits:
Reference
  • Object
show all
Defined in:
lib/hammer_cli_foreman/output/fields.rb

Instance Method Summary collapse

Methods inherited from Reference

#initialize

Constructor Details

This class inherits a constructor from Fields::Reference

Instance Method Details

#display?(value) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
# File 'lib/hammer_cli_foreman/output/fields.rb', line 40

def display?(value)
  id_key = @options[:id_key]
  display_key = @options[:display_field_key]

  (value[display_key.to_sym] || value[display_key]) && (value[id_key.to_sym] || value[id_key])
end

#initialize_optionsObject



31
32
33
34
35
36
37
38
# File 'lib/hammer_cli_foreman/output/fields.rb', line 31

def initialize_options
  key = @options[:key]
  display_field = @options[:display_field] || 'name'

  @options[:id_key] ||= "#{key}_id"
  @options[:display_field_key] ||= "#{key}_#{display_field}"
  super
end