Class: Aureus::Components::DataTable
- Inherits:
-
Renderable
show all
- Includes:
- ActionView::Helpers::JavaScriptHelper
- Defined in:
- lib/aureus/components/data_table.rb
Instance Method Summary
collapse
Methods inherited from Renderable
#compact, #compact_render, #content_tag, #init
Constructor Details
#initialize(resource) {|_self| ... } ⇒ DataTable
Returns a new instance of DataTable.
6
7
8
9
10
11
|
# File 'lib/aureus/components/data_table.rb', line 6
def initialize(resource, &block)
@resource = resource
@head = DataTableHead.new
@rows = Array.new
yield(self)
end
|
Instance Method Details
#head {|@head| ... } ⇒ Object
13
14
15
|
# File 'lib/aureus/components/data_table.rb', line 13
def head
yield @head
end
|
#render ⇒ Object
25
26
27
28
29
|
# File 'lib/aureus/components/data_table.rb', line 25
def render
content_tag 'table', id: @resource.class.name.downcase, class: 'aureus-datatable' do
compact @head.render, content_tag('tbody',compact_render(*@rows))
end
end
|
#row ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/aureus/components/data_table.rb', line 17
def row
@resource.each do |r|
row = DataTableRow.new
yield row, r
@rows << row
end
end
|