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)


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

Returns:

  • (Boolean)


25
26
27
# File 'app/models/spree/import_mapping.rb', line 25

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

#schema_field_labelString

Returns the label for the schema field

Returns:

  • (String)


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