Class: SimpleTable::Body

Inherits:
Rows
  • Object
show all
Defined in:
lib/simple_table/body.rb

Instance Attribute Summary

Attributes inherited from Rows

#rows

Attributes inherited from Tag

#options, #parent

Instance Method Summary collapse

Methods inherited from Rows

#empty?, #initialize, #row

Methods inherited from Tag

#add_class, #collection_class, #collection_name, #head?, #initialize, #table

Constructor Details

This class inherits a constructor from SimpleTable::Rows

Instance Method Details

#renderObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/simple_table/body.rb', line 5

def render
  build
  super(''.tap do |html|
    table.collection.each_with_index do |record, ix|
      html << rows.map do |row|
        # FIXME: For some reason the options hash is accumulated from one row to the next.
        # Furthermore the rows instance variable only contains one row (should contain 3 when running render_test.rb)
        # This causes setting of the alternate class in render_test.rb to fail.
        # As a temporary fix we are resetting options here.
        row.instance_variable_set(:'@options', {})
        row.render(record, options_for_record(record, ix, options))
      end.join
    end
  end)
end