Class: Trestle::Table

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Autoload
Defined in:
lib/trestle/table.rb,
lib/trestle/table/row.rb,
lib/trestle/table/column.rb,
lib/trestle/table/builder.rb,
lib/trestle/table/automatic.rb,
lib/trestle/table/select_column.rb,
lib/trestle/table/actions_column.rb

Direct Known Subclasses

Automatic

Defined Under Namespace

Classes: ActionsColumn, Automatic, Builder, Column, Renderer, Row, SelectColumn

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Table

Returns a new instance of Table.



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

def initialize(options={})
  @options = options
  @columns = []
end

Instance Attribute Details

#columnsObject (readonly)

Returns the value of attribute columns.



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

def columns
  @columns
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#rowObject



40
41
42
# File 'lib/trestle/table.rb', line 40

def row
  @row || Row.new(self)
end

Instance Method Details

#adminObject



20
21
22
# File 'lib/trestle/table.rb', line 20

def admin
  Trestle.lookup(options[:admin]) if options.key?(:admin)
end

#autolink?Boolean

Returns:

  • (Boolean)


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

def autolink?
  options[:autolink] != false
end

#header?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/trestle/table.rb', line 32

def header?
  options[:header] != false
end

#renderer(template) ⇒ Object



36
37
38
# File 'lib/trestle/table.rb', line 36

def renderer(template)
  Renderer.new(self, template)
end

#sortable?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/trestle/table.rb', line 24

def sortable?
  options[:sortable] == true
end