Class: Array

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

Direct Known Subclasses

Tablesmith::Table

Instance Method Summary collapse

Instance Method Details

#to_tableObject



161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/tablesmith/table.rb', line 161

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