Class: Decidim::EnhancedTextwork::ParagraphCreator

Inherits:
Admin::Import::Creator
  • Object
show all
Defined in:
lib/decidim/enhanced_textwork/paragraph_creator.rb

Overview

This class is responsible for creating the imported paragraphs and must be included in paragraphs component's import manifest.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resource_klassObject

Retuns the resource class to be created with the provided data.



9
10
11
# File 'lib/decidim/enhanced_textwork/paragraph_creator.rb', line 9

def self.resource_klass
  Decidim::EnhancedTextwork::Paragraph
end

Instance Method Details

#finish!Object

Saves the paragraph



23
24
25
26
27
# File 'lib/decidim/enhanced_textwork/paragraph_creator.rb', line 23

def finish!
  super # resource.save!
  notify(resource)
  publish(resource)
end

#produceObject

Produces a paragraph from parsed data

Returns a paragraph



16
17
18
19
20
# File 'lib/decidim/enhanced_textwork/paragraph_creator.rb', line 16

def produce
  resource.add_coauthor(context[:current_user], user_group: context[:user_group])

  resource
end