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



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/tablesmith/table.rb', line 153

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)
    if b.first && b.first.is_a?(ActiveRecord::Base)
      b.extend Tablesmith::ActiveRecordSource
    end
  end

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

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

  b
end