Class: TableHelper::TableBuilder

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tablematic/builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(records, attr, opts = {}) ⇒ TableBuilder

Returns a new instance of TableBuilder.



6
7
8
9
10
11
12
13
# File 'lib/tablematic/builder.rb', line 6

def initialize(records, attr, opts={})
  @records = records
  @attr = attr
  @model = @records.first.class
  @namespace = opts.fetch(:namespace,'')
  @config = Tablematic.configuration
  @opts = opts
end

Instance Method Details

#build(view_context, &block) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/tablematic/builder.rb', line 15

def build(view_context, &block)
  @view_context = view_context
  (:table, class: table_classes) do
    emit_html_heading +
    emit_html_rows(&block)
  end.html_safe
end