Class: Pulitzer::CreateFreeFormSectionPartials

Inherits:
Object
  • Object
show all
Defined in:
app/interactions/pulitzer/create_free_form_section_partials.rb

Instance Method Summary collapse

Constructor Details

#initialize(partial_type) ⇒ CreateFreeFormSectionPartials

Returns a new instance of CreateFreeFormSectionPartials.



3
4
5
# File 'app/interactions/pulitzer/create_free_form_section_partials.rb', line 3

def initialize(partial_type)
  @partial_type = partial_type
end

Instance Method Details

#callObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/interactions/pulitzer/create_free_form_section_partials.rb', line 7

def call
  free_form_section_type  = @partial_type.free_form_section_type
  post_type               = free_form_section_type.post_type
  post_type.posts.each do |post|
    if post.preview_version
      free_form_section = post.preview_version.free_form_sections.find_by(name: free_form_section_type.name)
      partial = free_form_section.partials.create do |p|
        p.label         = @partial_type.label
        p.sort_order    = @partial_type.sort_order
        p.post_type_id  = @partial_type.post_type_id
        p.layout_id      = @partial_type.layout_id
      end
      Pulitzer::CreatePartialContentElements.new(partial).call
    end
  end
end