Class: Trestle::Table::Builder

Inherits:
Builder
  • Object
show all
Defined in:
lib/trestle/table/builder.rb

Instance Method Summary collapse

Methods inherited from Builder

#build, build, target

Constructor Details

#initialize(options = {}) ⇒ Builder

Returns a new instance of Builder.



6
7
8
9
# File 'lib/trestle/table/builder.rb', line 6

def initialize(options={})
  @table = Table.new(options)
  @output_buffer = ActionView::OutputBuffer.new
end

Instance Method Details

#actions(options = {}, &block) ⇒ Object



28
29
30
# File 'lib/trestle/table/builder.rb', line 28

def actions(options={}, &block)
  table.columns << ActionsColumn.new(options, &block)
end

#column(field, proc = nil, options = {}, &block) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/trestle/table/builder.rb', line 19

def column(field, proc=nil, options={}, &block)
  if proc.is_a?(Hash)
    options = proc
    proc = nil
  end

  table.columns << Column.new(field, options, &(proc || block))
end

#row(options = {}, &block) ⇒ Object



11
12
13
# File 'lib/trestle/table/builder.rb', line 11

def row(options={}, &block)
  table.row = Row.new(options, &block)
end

#selectable_column(options = {}) ⇒ Object



15
16
17
# File 'lib/trestle/table/builder.rb', line 15

def selectable_column(options={})
  table.columns << SelectColumn.new(options)
end