Method: FilterTable::Table#field?

Defined in:
lib/utils/filter.rb

#field?(proposed_field) ⇒ Boolean

Returns:

  • (Boolean)


174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/utils/filter.rb', line 174

def field?(proposed_field)
  # Currently we only know about a field if it is present in a at least one row of the raw data.
  # If we have no rows in the raw data, assume all fields are acceptable (and rely on failing to match on value, nil)
  return true if raw_data.empty?

  # Most resources have Symbol keys in their raw data.  Some have Strings (looking at you, `shadow`).
  is_field = false
  is_field ||= list_fields.include?(proposed_field.to_s)
  is_field ||= list_fields.include?(proposed_field.to_sym)
  is_field ||= is_field_lazy?(proposed_field.to_s)
  is_field ||= is_field_lazy?(proposed_field.to_sym)

  is_field
end