Module: TableHelper

Defined in:
lib/table_builder/table_builder.rb

Defined Under Namespace

Classes: TableBuilder

Instance Method Summary collapse

Instance Method Details

#table_for(objects, *args) ⇒ Object

Raises:

  • (ArgumentError)


3
4
5
6
7
8
9
10
11
12
# File 'lib/table_builder/table_builder.rb', line 3

def table_for(objects, *args)
  raise ArgumentError, "Missing block" unless block_given?
  options = args.last.is_a?(Hash) ? args.pop : {}
  html_options = options[:html]
  builder = options[:builder] || TableBuilder

  (:table, html_options) do
    yield builder.new(objects || [], self, options)
  end
end