Sha256: 2d225e7a312aae182c04043d75958328b908391b67381e8fbe89884da0929d19

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

module MightyGrid
  class GridRenderer
    attr_reader :columns, :th_columns

    def initialize(grid, view)
      @columns = []
      @th_columns = []
    end

    def column(attr_or_options = {}, options=nil, &block)
      if block_given?
        options = attr_or_options.symbolize_keys
        @th_columns << {title: options[:title], html: options[:th_html]}
        @columns << MightyGrid::Column.new(options[:html], &block)
      else
        @columns << MightyGrid::Column.new(attr_or_options, options)
        th_column = {title: attr_or_options.to_s.titleize}
        th_column[:html] = options ? options[:th_html] : {}
        @th_columns << th_column
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mighty_grid-0.0.2 lib/mighty_grid/grid_renderer.rb