Module: Pageflow::EntryExportImport::RevisionSerialization

Extended by:
RevisionSerialization
Included in:
RevisionSerialization
Defined in:
lib/pageflow/entry_export_import/revision_serialization.rb,
lib/pageflow/entry_export_import/revision_serialization/import.rb

Overview

Turn revision into JSON compatible data structure.

Defined Under Namespace

Classes: Import

Constant Summary collapse

SERIALIZE_OPTIONS =
{
  except: [:entry_id, :creator_id],
  include: {
    widgets: {
      except: [:subject_id, :subject_type]
    },
    file_usages: {
      except: [:revision_id],
      include: {
        file: {
          except: [:entry_id, :job_id]
        }
      }
    }
  }
}.freeze

Instance Method Summary collapse

Instance Method Details

#dump(revision) ⇒ Object



24
25
26
27
28
# File 'lib/pageflow/entry_export_import/revision_serialization.rb', line 24

def dump(revision)
  revision
    .as_json(SERIALIZE_OPTIONS)
    .merge('components' => serialize_revision_components(revision))
end

#import(data, options) ⇒ Object



30
31
32
# File 'lib/pageflow/entry_export_import/revision_serialization.rb', line 30

def import(data, options)
  Import.new(**options).perform(data)
end