Sha256: 024706fba973481d993f24ca5363d7092583143de1c920dee1a7be5ae357a1f3
Contents?: true
Size: 767 Bytes
Versions: 1
Compression:
Stored size: 767 Bytes
Contents
require 'json' require 'tablinate/tag' require 'tablinate/table/thead' require 'tablinate/table/tbody' require 'tablinate/table' require 'tablinate/adapters/array' ## Thoughts: # Support column summing? # TODO: Support hidden columns? module Tablinate #turns an ActiveRecord::Relation into an array of hashes. def self.generate_table(objects, params={}) Table.new(self.parse_objects(objects), params) end private 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 end if defined?(Rails::Railtie) require 'tablinate/railtie' end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tablinate-1.2.3 | lib/tablinate.rb |