Sha256: a40bdbb5e3a0e77da12a22e316a97106c0441ec15cc3732e8cff06948bb0f75c

Contents?: true

Size: 1.21 KB

Versions: 40

Compression:

Stored size: 1.21 KB

Contents

# This helper wraps around the other table helpers i.e. Hirb::Helpers::Table while
# providing default helper options via Hirb::DynamicView. Using these default options, this
# helper supports views for the following modules/classes:
# ActiveRecord::Base, CouchFoo::Base, CouchPotato::Persistence, CouchRest::ExtendedDocument,
# DBI::Row, DataMapper::Resource, Friendly::Document, MongoMapper::Document, MongoMapper::EmbeddedDocument,
# Mongoid::Document, Ripple::Document, Sequel::Model.
class Hirb::Helpers::AutoTable < Hirb::Helpers::Table
  extend Hirb::DynamicView

  # Takes same options as Hirb::Helpers::Table.render except as noted below.
  #
  # ==== Options:
  # [:table_class] Explicit table class to use for rendering. Defaults to
  #                Hirb::Helpers::ObjectTable if output is not an Array or Hash. Otherwise
  #                defaults to Hirb::Helpers::Table.
  def self.render(output, options={})
    output = Array(output)
    (defaults = dynamic_options(output[0])) && (options = defaults.merge(options))
    klass = options.delete(:table_class) || (
      !(output[0].is_a?(Hash) || output[0].is_a?(Array)) ?
      Hirb::Helpers::ObjectTable : Hirb::Helpers::Table)
    klass.render(output, options)
  end
end

Version data entries

40 entries across 39 versions & 5 rubygems

Version Path
hirber-0.8.5 lib/hirb/helpers/auto_table.rb
hirber-0.8.4 lib/hirb/helpers/auto_table.rb
hirber-0.8.2 lib/hirb/helpers/auto_table.rb
hirber-0.8.1 lib/hirb/helpers/auto_table.rb
hirber-0.8.0 lib/hirb/helpers/auto_table.rb
hirb-0.7.3 lib/hirb/helpers/auto_table.rb
climine-0.0.7 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
climine-0.0.7 vendor/bundle/ruby/2.1.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
hirb-0.7.2 lib/hirb/helpers/auto_table.rb
climine-0.0.6 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
climine-0.0.5 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
climine-0.0.4 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
climine-0.0.3 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
climine-0.0.2 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
climine-0.0.1 vendor/bundle/ruby/2.0.0/gems/hirb-0.7.1/lib/hirb/helpers/auto_table.rb
hirb-0.7.1 lib/hirb/helpers/auto_table.rb
hirb-0.7.0 lib/hirb/helpers/auto_table.rb
hirb-0.6.2 lib/hirb/helpers/auto_table.rb
hirb-0.6.1 lib/hirb/helpers/auto_table.rb
hsume2-hirb-0.6.3 lib/hirb/helpers/auto_table.rb