Sha256: cd0c1ac417d758267de8f6388692d5394c0cb92753b8dda8696d1d54ccfa4792

Contents?: true

Size: 980 Bytes

Versions: 7

Compression:

Stored size: 980 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    class BodyRowComponent < ViewComponent::Base # :nodoc:
      include Katalyst::HtmlAttributes

      renders_many :columns, ->(component) { component }

      def initialize(table, record)
        super()

        @table  = table
        @record = record
      end

      def call
        content # generate content before rendering

        tag.tr(**html_attributes) do
          columns.each do |column|
            concat(column.to_s)
          end
        end
      end

      def cell(attribute, **options, &block)
        with_column(@table.body_cell_component.new(@table, @record, attribute, **options), &block)
      end

      def header?
        false
      end

      def body?
        true
      end

      def inspect
        "#<#{self.class.name} record: #{record.inspect}>"
      end

      # Backwards compatibility with tables 1.0
      alias_method :options, :html_attributes=
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katalyst-tables-2.6.0.beta app/components/katalyst/tables/body_row_component.rb
katalyst-tables-2.5.0 app/components/katalyst/tables/body_row_component.rb
katalyst-tables-2.4.0 app/components/katalyst/tables/body_row_component.rb
katalyst-tables-2.3.1 app/components/katalyst/tables/body_row_component.rb
katalyst-tables-2.3.0 app/components/katalyst/tables/body_row_component.rb
katalyst-tables-2.2.12 app/components/katalyst/tables/body_row_component.rb
katalyst-tables-2.2.11 app/components/katalyst/tables/body_row_component.rb