Sha256: dbe97cd3570d48d734e612da932ddc1dee7660029574ed6a2dbe327b573ed82b
Contents?: true
Size: 794 Bytes
Versions: 36
Compression:
Stored size: 794 Bytes
Contents
module Pageflow module EntryExportImport class FileMappings def initialize @file_mappings = {} end def find_or_store(exported_file_id, file_type) imported_file_id = @file_mappings.dig(file_type.model.name, exported_file_id) if imported_file_id.present? imported_file_id else file = yield @file_mappings[file_type.model.name] ||= {} @file_mappings[file_type.model.name][exported_file_id] = file.id file.id end end def imported_id_for(model_name, exported_id) @file_mappings.fetch(model_name)[exported_id] end def exported_id_for(model_name, imported_id) @file_mappings.fetch(model_name).invert[imported_id] end end end end
Version data entries
36 entries across 36 versions & 1 rubygems