Class: SimpleDataPresentation::SimpleTable::Body

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

Instance Method Summary collapse

Methods inherited from Base

#item, #title, #value

Constructor Details

#initialize(context, collection, options = {}, &content_block) ⇒ Body

Returns a new instance of Body.



2
3
4
5
6
7
# File 'lib/simple_data_presentation/simple_table/body.rb', line 2

def initialize(context, collection, options = {}, &content_block)
	@context = context
	@collection = collection
	@options = options
	@content_block = content_block
end

Instance Method Details

#render!Object



9
10
11
12
13
14
15
16
17
# File 'lib/simple_data_presentation/simple_table/body.rb', line 9

def render!
	html_options = @options.delete :tbody_html
	row_options = @options.merge :html => @options.delete(:row_html)
	rows_content = @collection.map do |resource|
		tr = SimpleDataPresentation::SimpleTable::Row.new @context, resource, row_options, &@content_block
		tr.render!
	end
	@context.raw @context. :tbody, rows_content.join.html_safe, html_options
end