Module: TableHelper

Defined in:
lib/table_builder/table_builder.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) table_for(objects, *args)

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