Sha256: 14151722356ad6edc5a5f93602f4b64741c04bd285470403ff4b1d5d1f2f9a93

Contents?: true

Size: 611 Bytes

Versions: 39

Compression:

Stored size: 611 Bytes

Contents

class Hirb::Helpers::ObjectTable < Hirb::Helpers::Table
  # Rows are any ruby objects. Takes same options as Hirb::Helpers::Table.render except as noted below.
  #
  # ==== Options:
  # [:fields] Methods of the object to represent as columns. Defaults to [:to_s].
  def self.render(rows, options ={})
    options[:fields] ||= [:to_s]
    options[:headers] ||= {:to_s=>'value'} if options[:fields] == [:to_s]
    item_hashes = options[:fields].empty? ? [] : Array(rows).inject([]) {|t,item|
      t << options[:fields].inject({}) {|h,f| h[f] = item.__send__(f); h}
    }
    super(item_hashes, options)
  end
end

Version data entries

39 entries across 38 versions & 5 rubygems

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