Module: Lcms::Engine::Partable

Included in:
Document, Material
Defined in:
app/models/concerns/lcms/engine/partable.rb

Instance Method Summary collapse

Instance Method Details

#create_parts_for(template) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/models/concerns/lcms/engine/partable.rb', line 6

def create_parts_for(template)
  template.parts.each do |part|
    document_parts.create!(
      active: true,
      anchor: part[:anchor],
      content: part[:content],
      context_type: part[:context_type],
      data: part[:data],
      materials: part[:materials],
      optional: part[:optional],
      part_type: part[:part_type],
      placeholder: part[:placeholder]
    )
  end
end

#layout(context_type) ⇒ Object



22
23
24
# File 'app/models/concerns/lcms/engine/partable.rb', line 22

def layout(context_type)
  document_parts.where(part_type: :layout, context_type: DocumentPart.context_types[context_type.to_sym]).last
end