Class: Pageflow::EntryExportImport::RevisionSerialization::Import

Inherits:
Object
  • Object
show all
Defined in:
lib/pageflow/entry_export_import/revision_serialization/import.rb

Overview

Turn revision into JSON compatible data structure.

Constant Summary collapse

DEFAULT_REMOVAL_COLUMNS =
%w[id updated_at].freeze
COMMON_FILE_COLUMNS =
%w[entry_id rights created_at uploader_id
confirmed_by_id parent_file_id parent_file_model_type].freeze

Instance Method Summary collapse

Constructor Details

#initialize(entry:, creator:, file_mappings: FileMappings.new) ⇒ Import

Returns a new instance of Import.



10
11
12
13
14
# File 'lib/pageflow/entry_export_import/revision_serialization/import.rb', line 10

def initialize(entry:, creator:, file_mappings: FileMappings.new)
  @entry = entry
  @creator = creator
  @file_mappings = file_mappings
end

Instance Method Details

#perform(data) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pageflow/entry_export_import/revision_serialization/import.rb', line 16

def perform(data)
  Revision.transaction do
    revision = create_revision(data)

    create_widgets(revision, data['widgets'])
    create_revision_components(revision, data['components'])
    create_files(revision, data['file_usages'])

    revision
  end
end