Class: Decidim::Pages::DataImporter

Inherits:
Importers::Importer
  • Object
show all
Defined in:
app/serializers/decidim/pages/data_importer.rb

Overview

Importer for Pages specific data (i.e. its page content).

Instance Method Summary collapse

Constructor Details

#initialize(component) ⇒ DataImporter

Returns a new instance of DataImporter.



7
8
9
# File 'app/serializers/decidim/pages/data_importer.rb', line 7

def initialize(component)
  @component = component
end

Instance Method Details

#import(serialized, _user) ⇒ Decidim::Pages::Page

Creates a new Decidim::Pages::Page associated to the given component for the serialized page object.

Parameters:

  • serialized (Hash)

    The serialized data read from the import file.

  • _user (Decidim::User)

    The user performing the import.

Returns:



17
18
19
20
21
22
23
24
# File 'app/serializers/decidim/pages/data_importer.rb', line 17

def import(serialized, _user)
  return unless serialized

  Page.create!(
    component: @component,
    body: serialized["body"]
  )
end