Sha256: 37b45366b9e52517eb5588ff78d08cdd8e4cd0f75d458a256259169d75305f11

Contents?: true

Size: 525 Bytes

Versions: 4

Compression:

Stored size: 525 Bytes

Contents

# Attempts to autodetect the table class the output represents and delegates rendering to it.
class Hirb::Helpers::AutoTable
  # Same options as Hirb::Helpers::Table.render.
  def self.render(output, options={})
    klass = if ((output.is_a?(Array) && output[0].is_a?(ActiveRecord::Base)) or output.is_a?(ActiveRecord::Base) rescue false)
      Hirb::Helpers::ActiveRecordTable
    elsif options[:fields]
      Hirb::Helpers::ObjectTable
    else
      Hirb::Helpers::Table
    end
    klass.render(output, options)
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
cldwalker-hirb-0.1.0 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.1.1 lib/hirb/helpers/auto_table.rb
cldwalker-hirb-0.1.2 lib/hirb/helpers/auto_table.rb
hirb-0.1.2 lib/hirb/helpers/auto_table.rb