Class: Hirb::Helpers::AutoTable
- Inherits:
-
Object
- Object
- Hirb::Helpers::AutoTable
- Defined in:
- lib/hirb/helpers/auto_table.rb
Overview
Detects the table class the output should use and delegates rendering to it.
Class Method Summary collapse
-
.render(output, options = {}) ⇒ Object
Same options as Hirb::Helpers::Table.render.
Class Method Details
.render(output, options = {}) ⇒ Object
Same options as Hirb::Helpers::Table.render.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/hirb/helpers/auto_table.rb', line 4 def self.render(output, ={}) output = output.to_a if !output.is_a?(Array) && output.respond_to?(:to_a) klass = if ((output.is_a?(Array) && output[0].is_a?(ActiveRecord::Base)) or output.is_a?(ActiveRecord::Base) rescue false) Hirb::Helpers::ActiveRecordTable elsif (output.is_a?(Array) && !(output[0].is_a?(Hash) || output[0].is_a?(Array))) Hirb::Helpers::ObjectTable else Hirb::Helpers::Table end klass.render(output, ) end |