Class: TableFor::TableBuilder
- Inherits:
-
Struct
- Object
- Struct
- TableFor::TableBuilder
- Defined in:
- lib/table_for/table_builder.rb
Instance Attribute Summary collapse
-
#table ⇒ Object
Returns the value of attribute table.
Instance Method Summary collapse
- #body(*columns, &block) ⇒ Object
- #columns(*columns) ⇒ Object
- #foot(&block) ⇒ Object
- #head(*columns) ⇒ Object
Instance Attribute Details
#table ⇒ Object
Returns the value of attribute table
2 3 4 |
# File 'lib/table_for/table_builder.rb', line 2 def table @table end |
Instance Method Details
#body(*columns, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/table_for/table_builder.rb', line 20 def body(*columns, &block) content_tag(:tbody) do table.row_builders.map do |builder| if TableFor.row_filter.call(table, builder.record) content_tag(:tr) do if block then capture(builder, &block) else builder.cells(*columns) end end end end.compact.join.html_safe end end |
#columns(*columns) ⇒ Object
6 7 8 |
# File 'lib/table_for/table_builder.rb', line 6 def columns(*columns) head(*columns) + body(*columns) end |
#foot(&block) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/table_for/table_builder.rb', line 32 def foot(&block) if TableFor..call(table) content_tag(:tfoot) do content_tag(:tr) do content_tag(:td, capture(&block), :colspan => table.columns.size) end end.html_safe end end |
#head(*columns) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/table_for/table_builder.rb', line 10 def head(*columns) table.columns = columns content_tag(:thead) do content_tag(:tr) do human_column_names.map { |column| content_tag(:th, column) }.join.html_safe end end end |