Sha256: de00c8f5eb36361593cd2f4c067c0eb697a32142528e928a78341a918e8589db

Contents?: true

Size: 821 Bytes

Versions: 2

Compression:

Stored size: 821 Bytes

Contents

module DryCrud
  module Table

    # Helper class to store column information.
    class Col #:nodoc:

      delegate :content_tag, :capture, to: :template

      attr_reader :header, :html_options, :template, :block

      def initialize(header, html_options, template, block)
        @header = header
        @html_options = html_options
        @template = template
        @block = block
      end

      # Runs the Col block for the given entry.
      def content(entry)
        entry.nil? ? '' : capture(entry, &block)
      end

      # Renders the header cell of the Col.
      def html_header
        content_tag(:th, header, html_options)
      end

      # Renders a table cell for the given entry.
      def html_cell(entry)
        content_tag(:td, content(entry), html_options)
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dry_crud-6.0.0 app/helpers/dry_crud/table/col.rb
dry_crud-5.2.0 app/helpers/dry_crud/table/col.rb