Class: Spree::ImportMapping

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/import_mapping.rb

Instance Method Summary collapse

Instance Method Details

#mapped?Boolean

Returns true if the mapping has a file column

Returns:

  • (Boolean)


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

Returns:

  • (Boolean)


23
24
25
# File 'app/models/spree/import_mapping.rb', line 23

def required?
  import.required_fields.include?(schema_field)
end

#schema_field_labelString

Returns the label for the schema field

Returns:

  • (String)


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