Class: Trestle::Table::Renderer

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

Instance Method Summary collapse

Constructor Details

#initialize(table, template) ⇒ Renderer

Returns a new instance of Renderer.



52
53
54
# File 'lib/trestle/table.rb', line 52

def initialize(table, template)
  @table, @template = table, template
end

Instance Method Details

#classesObject



68
69
70
# File 'lib/trestle/table.rb', line 68

def classes
  ["trestle-table", options[:class]].compact
end

#columnsObject



60
61
62
# File 'lib/trestle/table.rb', line 60

def columns
  @columns ||= row.columns
end

#dataObject



72
73
74
75
76
77
78
79
# File 'lib/trestle/table.rb', line 72

def data
  data = options[:data] || {}

  controllers = Array(data[:controller])
  controllers << "checkbox-select"

  data.merge(controller: controllers.join(" "))
end

#idObject



64
65
66
# File 'lib/trestle/table.rb', line 64

def id
  options[:id]
end

#rowObject



56
57
58
# File 'lib/trestle/table.rb', line 56

def row
  @row ||= @table.row.renderer(table: @table, template: @template)
end