Class: ODFReport::Section

Inherits:
Nestable show all
Defined in:
lib/odf-report/section.rb

Instance Method Summary collapse

Methods inherited from Nestable

#add_field, #add_image, #add_section, #add_table, #add_text, #all_images, #initialize, #set_source, #wrap_with_ns

Constructor Details

This class inherits a constructor from ODFReport::Nestable

Instance Method Details

#replace!(doc) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/odf-report/section.rb', line 4

def replace!(doc)

  return unless find_section_node(doc)

  @data_source.each do |record|

    new_section = deep_clone(@section_node)

    @tables.each    { |t| t.set_source(record).replace!(new_section) }
    @sections.each  { |s| s.set_source(record).replace!(new_section) }
    @texts.each     { |t| t.set_source(record).replace!(new_section) }
    @fields.each    { |f| f.set_source(record).replace!(new_section) }
    @images.each    { |i| i.set_source(record).replace!(new_section) }

    @section_node.before(new_section.to_xml)

  end

  @section_node.remove

end