Class: Spree::ImportMapping
- Inherits:
-
Object
- Object
- Spree::ImportMapping
- Defined in:
- app/models/spree/import_mapping.rb
Instance Method Summary collapse
-
#mapped? ⇒ Boolean
Returns true if the mapping has a file column.
-
#required? ⇒ Boolean
Returns true if the mapping is required.
-
#schema_field_label ⇒ String
Returns the label for the schema field.
- #try_to_auto_assign_file_column(csv_headers) ⇒ Object
Instance Method Details
#mapped? ⇒ Boolean
Returns true if the mapping has a file column
31 32 33 |
# File 'app/models/spree/import_mapping.rb', line 31 def mapped? file_column.present? end |
#required? ⇒ Boolean
Returns true if the mapping is required
25 26 27 |
# File 'app/models/spree/import_mapping.rb', line 25 def required? import.required_fields.include?(schema_field) end |
#schema_field_label ⇒ String
Returns the label for the schema field
41 42 43 44 45 46 |
# File 'app/models/spree/import_mapping.rb', line 41 def schema_field_label @schema_field_label ||= begin field = import.schema_fields.find { |field| field[:name] == schema_field } field[:label] if field.present? end end |
#try_to_auto_assign_file_column(csv_headers) ⇒ Object
35 36 37 |
# File 'app/models/spree/import_mapping.rb', line 35 def try_to_auto_assign_file_column(csv_headers) self.file_column = csv_headers.find { |header| header.parameterize.underscore.downcase.strip == schema_field.parameterize.underscore.downcase.strip } end |