Sha256: 59f8d252a2896963d2b14753d41841bc9054813cd36c808a98b556f5ae921ffc

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'table_go/version'

module TableGo
  autoload :Table, 'table_go/table'
  autoload :Columns, 'table_go/columns'
  autoload :Column, 'table_go/column'
  autoload :TableRenderer, 'table_go/table_renderer'
  autoload :Renderers, 'table_go/renderers'
  autoload :Formatter, 'table_go/formatter'
  autoload :Helpers, 'table_go/helpers'


  def self.render_html(collection, model_klass, template, options = {}, &block)
    render(collection, model_klass, TableGo::Renderers::HtmlRenderer, template, options, &block)
  end

  def self.render_csv(collection, model_klass, options = {}, &block)
    render(collection, model_klass, TableGo::Renderers::CsvRenderer, nil, options, &block)
  end

  def self.render(collection, model_klass, renderer_klass, template, options = {}, &block)
    table     = Table.new(collection, model_klass, &block)
    renderer  = TableRenderer.new(table)
    renderer.renderer_klass = renderer_klass
    renderer.template       = template
    renderer.apply_options(options)
    renderer.render_template
  end

end

require 'table_go/railtie' if defined?(Rails)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
table_go-0.1.9 lib/table_go.rb