Class: Array

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

Instance Method Summary collapse

Instance Method Details

#to_tableObject



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/tablesmith/table.rb', line 172

def to_table
  b = Tablesmith::Table.new(self)

  # TODO: redesign such that every row is reacted to appropriately,
  # so mixed content could be supported. Maybe every cell could be
  # rendered appropriately, with nested tables.
  if defined?(ActiveRecord) && defined?(ActiveRecord::Base)
    b.extend Tablesmith::ActiveRecordSource if b.first&.is_a?(ActiveRecord::Base)
  end

  b.extend Tablesmith::HashRowsSource if b.first&.is_a?(Hash)

  b.extend Tablesmith::ArrayRowsSource if b.first&.is_a?(Array)

  b
end