Sha256: 49ea5c2c497d1e1386bf1ab5f39e74bca960a141d52826620231414da9843467
Contents?: true
Size: 726 Bytes
Versions: 12
Compression:
Stored size: 726 Bytes
Contents
module TableBuilder class Body < Rows self.tag_name = :tbody include ActionView::RecordIdentifier def row(options = {}, &block) table.collection.each_with_index do |record, ix| super(record, options_for_record(record, ix, options)) end end protected def build row do |row, record| row.cell *table.columns.map { |column| record.send(column.attribute_name) } end if @rows.empty? end def options_for_record(record, ix, options = {}) options = options.dup options[:id] = dom_id(record) if record.respond_to?(:new_record?) add_class!(options, 'alternate') if ix % 2 == 1 options end end end
Version data entries
12 entries across 12 versions & 2 rubygems