app/models/import.rb in geoblacklight_admin-0.0.1 vs app/models/import.rb in geoblacklight_admin-0.1.0
- old
+ new
@@ -92,13 +92,11 @@
transformed_data = {}
mappings.each do |mapping|
# logger.debug("Mapping: #{mapping.source_header} to #{mapping.destination_field}")
# Handle discards
- if mapping.destination_field == "Discard"
- next
- end
+ next if mapping.destination_field == "Discard"
# Handle repeatable dct_references_s entries
if mapping.destination_field == "dct_references_s"
transformed_data[mapping.destination_field] ||= []
if extract_hash[mapping.source_header].present?
@@ -116,11 +114,12 @@
transformed_data[mapping.destination_field] = extract_hash[mapping.source_header]
end
# Split delimited field values, if field has a value present
if mapping.delimited?
- transformed_data[mapping.destination_field] = transformed_data[mapping.destination_field].present? ? transformed_data[mapping.destination_field].split(klass_delimiter) : ""
+ transformed_data[mapping.destination_field] =
+ transformed_data[mapping.destination_field].present? ? transformed_data[mapping.destination_field].split(klass_delimiter) : ""
end
end
transformed_data
end
@@ -173,12 +172,10 @@
required_mappings.each do |mapping|
mapping.each do |key, value|
required_mapping = {}
required_mapping[key] = value
- unless data_hash.has_key?(key)
- data_hash.merge!(required_mapping.stringify_keys)
- end
+ data_hash.merge!(required_mapping.stringify_keys) unless data_hash.key?(key)
end
end
data_hash
end