Sha256: 5edea60a2ddfeca780dd95e08de6c183f9bd87fe375f9393844d23b654b14bec

Contents?: true

Size: 864 Bytes

Versions: 13

Compression:

Stored size: 864 Bytes

Contents

# frozen_string_literal: true

module Katalyst
  module Tables
    module HasTableContent # :nodoc:
      extend ActiveSupport::Concern

      def initialize(object_name: nil, partial: nil, as: nil, **options)
        super(**options)

        @object_name = object_name || model_name&.i18n_key
        @partial     = partial
        @as          = as
      end

      def model_name
        collection.model_name if collection.respond_to?(:model_name)
      end

      private

      def row_proc
        @row_proc ||= @__vc_render_in_block || method(:row_partial)
      end

      def row_partial(row, record = nil)
        partial = @partial || model_name&.param_key&.to_s
        as      = @as || model_name&.param_key&.to_sym
        render(partial: partial, variants: [:row], formats: [:html], locals: { as => record, row: row })
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
katalyst-tables-2.3.1 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.3.0 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.12 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.11 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.10 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.9 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.8 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.7 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.6 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.5 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.4 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.3 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.2.2 app/components/concerns/katalyst/tables/has_table_content.rb