Class: Pageflow::EntryExportImport::FileMappings Private
- Inherits:
-
Object
- Object
- Pageflow::EntryExportImport::FileMappings
- Defined in:
- lib/pageflow/entry_export_import/file_mappings.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #exported_id_for(model_name, imported_id) ⇒ Object private
- #find_or_store(exported_file_id, file_type) ⇒ Object private
- #imported_id_for(model_name, exported_id) ⇒ Object private
-
#initialize ⇒ FileMappings
constructor
private
A new instance of FileMappings.
Constructor Details
#initialize ⇒ FileMappings
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of FileMappings.
5 6 7 |
# File 'lib/pageflow/entry_export_import/file_mappings.rb', line 5 def initialize @file_mappings = {} end |
Instance Method Details
#exported_id_for(model_name, imported_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/pageflow/entry_export_import/file_mappings.rb', line 28 def exported_id_for(model_name, imported_id) @file_mappings.fetch(model_name).invert[imported_id] end |
#find_or_store(exported_file_id, file_type) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/pageflow/entry_export_import/file_mappings.rb', line 9 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 |
#imported_id_for(model_name, exported_id) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/pageflow/entry_export_import/file_mappings.rb', line 24 def imported_id_for(model_name, exported_id) @file_mappings.fetch(model_name)[exported_id] end |