Sha256: 7fcf0c40e8cd5dd34730593165ed14c89e5e036eaed1094372770afff0f032c3

Contents?: true

Size: 747 Bytes

Versions: 1

Compression:

Stored size: 747 Bytes

Contents

module Trestle
  class Table
    class Builder < Trestle::Builder
      target :table

      def initialize(options={})
        @table = Table.new(options)
        @output_buffer = ActionView::OutputBuffer.new
      end

      def row(options={}, &block)
        table.row = Row.new(table, options, &block)
      end

      def selectable_column
        table.columns << SelectColumn.new(table)
      end

      def column(field, proc=nil, options={}, &block)
        if proc.is_a?(Hash)
          options = proc
          proc = nil
        end

        table.columns << Column.new(table, field, options, &(proc || block))
      end

      def actions(&block)
        table.columns << ActionsColumn.new(table, &block)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
trestle-0.8.4 lib/trestle/table/builder.rb