Sha256: 04495aa9ea7e94c998c8f6975fbb99ec993f8b0d9598c8de0e2986c4f54128ba

Contents?: true

Size: 647 Bytes

Versions: 14

Compression:

Stored size: 647 Bytes

Contents

# Detects the table class the output should use and delegates rendering to it.
class Hirb::Helpers::AutoTable
  # Same options as Hirb::Helpers::Table.render.
  def self.render(output, options={})
    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, options)
  end
end

Version data entries

14 entries across 14 versions & 3 rubygems

Version Path
Chrononaut-hirb-0.2.1 lib/hirb/helpers/auto_table.rb
Chrononaut-hirb-0.2.3 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.2.2 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.2.3 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.2.4 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.2.5 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.2.6 lib/hirb/helpers/auto_table.rb
hirb-0.2.8 lib/hirb/helpers/auto_table.rb
hirb-0.2.7 lib/hirb/helpers/auto_table.rb
hirb-0.2.6 lib/hirb/helpers/auto_table.rb
hirb-0.2.2 lib/hirb/helpers/auto_table.rb
hirb-0.2.3 lib/hirb/helpers/auto_table.rb
hirb-0.2.4 lib/hirb/helpers/auto_table.rb
hirb-0.2.5 lib/hirb/helpers/auto_table.rb