module Tablinate

Thoughts:

Support column summing? TODO: Support hidden columns?

Constants

VERSION

Public Class Methods

generate_table(objects, params={}) click to toggle source

turns an ActiveRecord::Relation into an array of hashes.

# File lib/tablinate.rb, line 12
def self.generate_table(objects, params={})
  Table.new(self.parse_objects(objects), params)
end

Private Class Methods

parse_objects(objects) click to toggle source
# File lib/tablinate.rb, line 17
def self.parse_objects(objects)
  if objects.class == String then
    return JSON.parse(objects)
  elsif objects.class.to_s == "ActiveRecord::Relation"
      return objects.collect{ |x| x.attributes }
  else
    return objects
  end
end