Sha256: cb2c1c7a7938467f69df920a79b2da76b5b692dddee9184b6c307767a40b5a04

Contents?: true

Size: 789 Bytes

Versions: 4

Compression:

Stored size: 789 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(options={})
        table.columns << SelectColumn.new(table, options)
      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(options={}, &block)
        table.columns << ActionsColumn.new(table, options, &block)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
trestle-0.9.2 lib/trestle/table/builder.rb
trestle-0.9.1 lib/trestle/table/builder.rb
trestle-0.9.0 lib/trestle/table/builder.rb
trestle-0.8.13 lib/trestle/table/builder.rb