Class: TableFor::Table

Inherits:
Struct
  • Object
show all
Defined in:
lib/table_for/table.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



2
3
4
# File 'lib/table_for/table.rb', line 2

def block
  @block
end

#columnsObject

Returns the value of attribute columns.



3
4
5
# File 'lib/table_for/table.rb', line 3

def columns
  @columns
end

#htmlObject

Returns the value of attribute html

Returns:

  • (Object)

    the current value of html



2
3
4
# File 'lib/table_for/table.rb', line 2

def html
  @html
end

#model_classObject

Returns the value of attribute model_class

Returns:

  • (Object)

    the current value of model_class



2
3
4
# File 'lib/table_for/table.rb', line 2

def model_class
  @model_class
end

#recordsObject

Returns the value of attribute records

Returns:

  • (Object)

    the current value of records



2
3
4
# File 'lib/table_for/table.rb', line 2

def records
  @records
end

#rowsObject

Returns the value of attribute rows.



3
4
5
# File 'lib/table_for/table.rb', line 3

def rows
  @rows
end

#templateObject

Returns the value of attribute template

Returns:

  • (Object)

    the current value of template



2
3
4
# File 'lib/table_for/table.rb', line 2

def template
  @template
end

Instance Method Details

#human_column_namesObject



6
7
8
# File 'lib/table_for/table.rb', line 6

def human_column_names
  columns.map { |column| model_class.human_attribute_name(column) }
end

#renderObject



14
15
16
17
18
# File 'lib/table_for/table.rb', line 14

def render
  (:table, :class => css_class) do
    caption + capture(TableBuilder.new(self), &block)
  end
end

#row_buildersObject



10
11
12
# File 'lib/table_for/table.rb', line 10

def row_builders
  records.map { |record| RowBuilder.new(self, record) }
end