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.

Yields:

  • (_self)

Yield Parameters:



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

Yields:



13
14
15
# File 'lib/aureus/components/data_table.rb', line 13

def head
  yield @head
end

#renderObject



25
26
27
28
29
# File 'lib/aureus/components/data_table.rb', line 25

def render
   'table', id: @resource.class.name.downcase, class: 'aureus-datatable' do
    compact @head.render, ('tbody',compact_render(*@rows))
  end
end

#rowObject



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