Module: MappingsHelper
- Defined in:
- app/helpers/mappings_helper.rb
Overview
MappingsHelper
This module provides helper methods for handling mappings in the application. It includes methods to generate attribute collections and provide mapping and delimiter suggestions based on import configurations.
Instance Method Summary collapse
-
#attribute_collection ⇒ Array<String>
Returns a collection of attributes that can be used for mapping.
-
#delimiter_suggestion(import, header) ⇒ String, false
Provides a delimiter suggestion for a given header based on the import configuration.
-
#mapping_suggestion(import, header) ⇒ String, false
Provides a mapping suggestion for a given header based on the import configuration.
Instance Method Details
#attribute_collection ⇒ Array<String>
Returns a collection of attributes that can be used for mapping.
The collection is generated from importable elements, sorted, and includes additional options for an empty string and “Discard”.
15 16 17 18 19 20 |
# File 'app/helpers/mappings_helper.rb', line 15 def attribute_collection attrs = Element.importable.map(&:solr_field).sort attrs.prepend("") attrs.prepend("Discard") attrs end |
#delimiter_suggestion(import, header) ⇒ String, false
Provides a delimiter suggestion for a given header based on the import configuration.
Checks if the header is included in the import’s mapping configuration and returns the delimiter if available.
46 47 48 49 50 51 52 |
# File 'app/helpers/mappings_helper.rb', line 46 def delimiter_suggestion(import, header) if import.mapping_configuration.include?(header.to_sym) import.mapping_configuration[header.to_sym][:delimited] else false end end |
#mapping_suggestion(import, header) ⇒ String, false
Provides a mapping suggestion for a given header based on the import configuration.
Checks if the header is included in the import’s mapping configuration and returns the destination if available.
30 31 32 33 34 35 36 |
# File 'app/helpers/mappings_helper.rb', line 30 def mapping_suggestion(import, header) if import.mapping_configuration.include?(header.to_sym) import.mapping_configuration[header.to_sym][:destination] else false end end |