Module: Pageflow::EntryExportImport::PageTypeVersions Private

Extended by:
PageTypeVersions
Included in:
PageTypeVersions
Defined in:
lib/pageflow/entry_export_import/page_type_versions.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: IncompatibleVersionsError

Instance Method Summary collapse

Instance Method Details

#dumpObject

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
# File 'lib/pageflow/entry_export_import/page_type_versions.rb', line 9

def dump
  Pageflow.config.page_types.each_with_object({}) do |page_type, version_requirements|
    version_requirements[page_type.name] = page_type.export_version
  end
end

#verify_compatibility!(data) ⇒ 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.



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

def verify_compatibility!(data)
  data.each do |page_type_name, export_version|
    page_type = Pageflow.config.page_types.find_by_name!(page_type_name)
    requirement = Gem::Requirement.new(page_type.import_version_requirement)

    next if requirement.satisfied_by?(Gem::Version.new(export_version))

    raise(IncompatibleVersionsError,
          "Export version #{export_version} of page type #{page_type_name}. " \
          "does not match #{requirement}")
  end
end