Sha256: 5eb4fb3b4b26a1ec1d2e6f2d8ce84ef3895c5e445201ef6d9e7d3efe35d562b7

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 KB

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
        if @row_proc
          @row_proc
        elsif @__vc_render_in_block
          @row_proc = @__vc_render_in_block
        else
          @row_proc = Proc.new do |row, object|
            row_renderer.render_row(row, object, view_context)
          end
        end
      end

      def row_renderer
        @row_renderer ||= RowRenderer.new(@lookup_context,
                                          collection:,
                                          as:         @as,
                                          partial:    @partial,
                                          variants:   [:row],
                                          formats:    [:html])
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
katalyst-tables-3.0.0.beta1 app/components/concerns/katalyst/tables/has_table_content.rb
katalyst-tables-2.6.0 app/components/concerns/katalyst/tables/has_table_content.rb