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
29 30 31 |
# File 'app/models/spree/import_mapping.rb', line 29 def mapped? file_column.present? end |
#required? ⇒ Boolean
Returns true if the mapping is required
23 24 25 |
# File 'app/models/spree/import_mapping.rb', line 23 def required? import.required_fields.include?(schema_field) end |
#schema_field_label ⇒ String
Returns the label for the schema field
39 40 41 42 43 44 |
# File 'app/models/spree/import_mapping.rb', line 39 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
33 34 35 |
# File 'app/models/spree/import_mapping.rb', line 33 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 |