Class: ActiveElement::Components::Util::FieldMapping

Inherits:
Object
  • Object
show all
Includes:
Translations
Defined in:
lib/active_element/components/util/field_mapping.rb

Overview

Utility class for converting field names to labels, CSS classes, and data mappers.

Instance Method Summary collapse

Methods included from Translations

#i18n, #model

Constructor Details

#initialize(component, fields, class_name) ⇒ FieldMapping

Returns a new instance of FieldMapping.



10
11
12
13
14
# File 'lib/active_element/components/util/field_mapping.rb', line 10

def initialize(component, fields, class_name)
  @component = component
  @class_name = class_name
  @fields = fields
end

Instance Method Details

#mapped_fieldsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_element/components/util/field_mapping.rb', line 16

def mapped_fields
  fields.map do |field|
    [
      field,
      class_mapper(field),
      field_to_label(field),
      decorated_value_mapper(field),
      options(field)
    ]
  end
end