Module: ForemanCustomTab::HostsHelperExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/helpers/concerns/foreman_custom_tab/hosts_helper_extensions.rb

Instance Method Summary collapse

Instance Method Details

#summary_fields(host) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/helpers/concerns/foreman_custom_tab/hosts_helper_extensions.rb', line 6

def summary_fields(host)
  fields = []
  rows = SETTINGS[:custom_tab][:fields] || []
  rows.each do |name, value|
    result = nil
    value.split('.').each_with_index do |method, index|
      result = index.eql?(0) ? host.try(method) : result.try(method)
    end
    fields += [[_(name.to_s), result]] if result.present?
  end
  fields
end